Welcome, guest | Sign In | My Account | Store | Cart

Calculates the number of trailing zeroes on the end of x! when the user inputs x.

Python, 10 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def Trailing_Zeroes(x):
    fives = 0
    for number in range(2, x+1):          
        while number > 0:
            if number % 5 == 0:
                fives += 1
                number = number/5
            else:
                break
    return fives
Created by Stijn de Graaf on Mon, 15 Aug 2011 (MIT)
Python recipes (4591)
Stijn de Graaf's recipes (5)

Required Modules

  • (none specified)

Other Information and Tasks