Skip to content

Conversation

@LesterKim
Copy link

Included zero factorial giving 1 and some typing as well as a more descriptive argument name.

def factorial_recursive(n):
return 1 if n is 1 else n * factorial_recursive(n-1)
def factorial_recursive(integer: int) -> int:
return 1 if integer is 0 else integer * factorial_recursive(integer - 1)
Copy link
Author

@LesterKim LesterKim Jul 18, 2020

Choose a reason for hiding this comment

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

A sleek but more cryptic alternative:

Suggested change
return 1 if integer is 0 else integer * factorial_recursive(integer - 1)
return int(integer is 0) or integer * factorial_recursive(integer - 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant