diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/factorial.py b/factorial.py index 3569741..7d5460a 100755 --- a/factorial.py +++ b/factorial.py @@ -7,17 +7,22 @@ def factorial(n): - # TODO Define your logic for factorial here - return # TODO! + # Define your logic for factorial here + if n == 1 or n == 0: + return 1 + else: + return n * factorial(n-1) + def test_factorial(): + # Tests the function with value 1 assert factorial(1) == 1 - # TODO: add more + assert factorial(0) == 1 + 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: ") - norders = factorial(nconditions) - print("Number of possible trial orders: " + str(norders) + # imported as a library, we should not run code below + conditions = int(input("Please enter number of conditions: ")) + orders = factorial(conditions) + print("Number of possible trial orders: " + str(orders))