m2skills

trailing python

Apr 7th, 2017
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. # program to find the trailing zeros in factorial of a given number
  2.  
  3. def findZeros(number):
  4. div = 5
  5. zeros = 0
  6. while number >= div:
  7. quotient = number/div
  8. zeros += quotient
  9. div *= 5
  10. zeros = int(zeros)
  11. print("The number of trailing zeros in the factorial of " + str(number) + " are " + str(zeros))
  12. return
  13.  
  14. #main function
  15. cont = True
  16. while cont:
  17. number = int(input("Enter the number : "))
  18. findZeros(number)
  19. n = int(input("Do you want to continue (1/0): "))
  20. if n == 0:
  21. cont = False
  22. print()
Add Comment
Please, Sign In to add comment