input: positive integer 'n' returns the factorial of 'n' (n!)
(n)
| 565 | # ----------------------------------------------------------------- |
| 566 | |
| 567 | def factorial(n): |
| 568 | """ |
| 569 | input: positive integer 'n' |
| 570 | returns the factorial of 'n' (n!) |
| 571 | """ |
| 572 | |
| 573 | # precondition |
| 574 | assert isinstance(n,int) and (n >= 0), "'n' must been a int and >= 0" |
| 575 | |
| 576 | ans = 1 # this will be return. |
| 577 | |
| 578 | for factor in range(1,n+1): |
| 579 | ans *= factor |
| 580 | |
| 581 | return ans |
| 582 | |
| 583 | # ------------------------------------------------------------------- |
| 584 |
nothing calls this directly
no outgoing calls
no test coverage detected