Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
def factorial(n):
  if n == 1:
    return 1
  else:
    return n * factorial(n-1)

number = -1
while number < 0:
  try:
    number = int(input("Give me a positive number: "))
  except:
    print("That wasn't a number.")
print(number,"factorial is",factorial(number))
Python 3.6.1 (default, Dec 2015, 13:05:11) [GCC 4.8.2] on linux