Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created factorial.py #12164

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions recursion/factorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def factorial(n):

Check failure on line 1 in recursion/factorial.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (INP001)

recursion/factorial.py:1:1: INP001 File `recursion/factorial.py` is part of an implicit namespace package. Add an `__init__.py`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there is no test file in this pull request nor any test function or class in the file recursion/factorial.py, please provide doctest for the function factorial

Please provide return type hint for the function: factorial. If the function does not return a value, please provide the type hint as: def function() -> None:

Please provide descriptive name for the parameter: n

Please provide type hint for the parameter: n

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def print_butterfly -> None:
n is used to ask the user to enter the length of butterfly

if n == 0 or n == 1:

Check failure on line 2 in recursion/factorial.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (PLR1714)

recursion/factorial.py:2:8: PLR1714 Consider merging multiple comparisons: `n in (0, 1)`. Use a `set` if the elements are hashable.
return 1
else:
return n * factorial(n - 1)

# Example
print(factorial(4))
Loading