def fact(n): if n < 0: return 'undefined' res = 1 for i in range(2, n+1): res *= i return res for i in range(-1, 5): print('{}! = {}'.format(i, fact(i)))
To embed this project on your website, copy the following code and paste it into your website's HTML: