input: positive integer 'n' returns the factorial of 'n' (n!)
(n)
| 594 | |
| 595 | |
| 596 | def factorial(n): |
| 597 | """ |
| 598 | input: positive integer 'n' |
| 599 | returns the factorial of 'n' (n!) |
| 600 | """ |
| 601 | |
| 602 | # precondition |
| 603 | assert isinstance(n, int) and (n >= 0), "'n' must been a int and >= 0" |
| 604 | |
| 605 | ans = 1 # this will be return. |
| 606 | |
| 607 | for factor in range(1, n + 1): |
| 608 | ans *= factor |
| 609 | |
| 610 | return ans |
| 611 | |
| 612 | |
| 613 | # ------------------------------------------------------------------- |
nothing calls this directly
no outgoing calls
no test coverage detected