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

Update factorial.py #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
16 changes: 11 additions & 5 deletions factorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@


def factorial(n):
# TODO Define your logic for factorial here
return # TODO!
if n == 0:
return 1
else:
return n*factorial(n-1)


def test_factorial():
assert factorial(1) == 1
# TODO: add more
assert factorial(0) == 1
assert factorial(2) == 2
assert factorial(3) == 6


if __name__ == '__main__':
# This is a way to determine either file was "executed", so if it was
# imported (by e.g. pytest) as a library, we should not run code
# below
nconditions = raw_input("Please enter number of conditions: ")
nconditions = input("Please enter number of conditions: ")
norders = factorial(nconditions)
print("Number of possible trial orders: " + str(norders)
print("Number of possible trial orders: " + str(norders))