Advertisement
yragi_san

Find the factorial of a number

Oct 6th, 2020
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. # number to find the factorial of
  2. number = 6
  3.  
  4. # start with our product equal to one
  5. product = 1
  6.  
  7. # track the current number being multiplied
  8. current = 1
  9.  
  10. # write your while loop here
  11. while current != number+1:
  12. # multiply the product so far by the current number
  13. product = product * current
  14. # increment current with each iteration until it reaches number
  15. current += 1
  16.  
  17.  
  18. # print the factorial of the number
  19. print(product)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement