Interview Solution

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Martin Golding

Trailing Zeros

Language Java | Level Intermediate | Category Interview Problems | July 24, 2015 4:52 pm

Comments


Interview Problem

Trailing zeros are a sequence of 0s in the decimal representation of a number, after which no other digits follow. Example 320 has one tailing zero.
The number if trailing zeros in the representation of factorial. The factorial is not negative integer number which is the product of numbers.
Example:-
Input 23, the factorial calculated by
23! = 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x 15 x 16 x 17 x 18 x 19 x 20 x 21 x 22 x 23
23! = 25852016738884976640000
Result = 4.


Output

   					 
The Trailing Zeros of 23!:4
The Trailing Zeros of 101!:24

				    

Comments



Please login to add comments.