Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # program to find factorial of a number using loops
- def factorial(number):
- fact = 1
- while number != 0:
- fact = fact * number
- number = number - 1
- return fact
- # main function
- cont = True
- while cont:
- number = int(input("Enter the number : "))
- answer = factorial(number)
- print("Factorial of " + str(number) + " is " + str(answer) )
- n = int(input("Do you want to continue (1/0) : "))
- if n == 0:
- cont = False
- print()
Add Comment
Please, Sign In to add comment