Skip to content

style(2_find_factorial): Restyle function with typing and extension#10

Open
LesterKim wants to merge 1 commit into
ByteAcademyCo:masterfrom
LesterKim:update-factorial
Open

style(2_find_factorial): Restyle function with typing and extension#10
LesterKim wants to merge 1 commit into
ByteAcademyCo:masterfrom
LesterKim:update-factorial

Conversation

@LesterKim

Copy link
Copy Markdown

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)

@LesterKim LesterKim Jul 18, 2020

Copy link
Copy Markdown
Author

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