diff --git a/factorial.py b/factorial.py index 3569741..1b8aecf 100755 --- a/factorial.py +++ b/factorial.py @@ -1,23 +1,25 @@ #!/usr/bin/env python """Module for estimation of factorial (Homework #1) - -Note: this is just a skeleton for you to work with. But it already - has some "bugs" you need to catch and fix. +Mohsen Rakhshan +Note: I am playing with this homework to learn git and ... """ def factorial(n): - # TODO Define your logic for factorial here - return # TODO! + + outputCalc = 1 + for number in range(1, n+1): + outputCalc = number * outputCalc + return outputCalc + def test_factorial(): - assert factorial(1) == 1 - # TODO: add more + assert factorial(2) == 1 + assert factorial(0) == 1 + assert factorial(-10) == 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: ") + nconditions = int(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))