Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inputNum = 5 #Number you would like to find the factorial
- i = 1 # i will be used as a counter
- total = 1 # this will be the total
- while i <= inputNum: # while i is less than or equal to inputNum
- total = total * i # total is equal to total * i. ex: total*1; total*2; total*3; etc..
- i = i + 1 # increments i each loop. adds 1 to i each time
- print "The factorial of " + str(inputNum) + " is: " + str(total) #prints the factorial of inputNum
- #str() simply converts an int into a String
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement