Number of zeros in the factorial X97024


Statement
 

pdf   zip   main.cc

Implement the function

    int nzeros_fact(int x);

which returns the number of ending zeroes in its factorial.

Take into account that ending zeros correspond to powers of 55 and, for each kk, the corresponding number of zeroes is i>0x/5i.\sum_{i>0} x/5^i.

Input

Input consists of an integer number.

Precondition

It holds 0<0 < @x@<109< 10^9.

Observation

You only need to submit the required procedure; your main program will be ignored.

Public test cases
  • Input/Output

    nzeros_fact(4) → 0
    nzeros_fact(5) → 1
    nzeros_fact(6) → 1
    nzeros_fact(9) → 1
    nzeros_fact(10) → 2
    nzeros_fact(11) → 2
    nzeros_fact(24) → 4
    nzeros_fact(25) → 6
    nzeros_fact(26) → 6
    nzeros_fact(124) → 28
    nzeros_fact(125) → 31
    nzeros_fact(126) → 31
    nzeros_fact(736, ) → 182
    nzeros_fact(3480) → 868
    nzeros_fact(78900) → 19724
    nzeros_fact(5000000) → 1249998
    nzeros_fact(500000000) → 124999999
  • Information
    Author
    Maria Serna
    Language
    English
    Translator
    Maria Serna
    Original language
    Catalan
    Other languages
    Catalan Spanish
    Official solutions
    Unknown.
    User solutions
    C++