Hey I am starting to tackle the factorial problem, but I do not understand the example input and output that are given as example. Can someone help me understand how the two correlate, please?

Sample Input:
6
3
60
100
1024
23456
8735373
Sample Output:
0
14
24
253
5861
2183837

What you need to do is => Find the Number of Trailing Zeroes at the end of N!

T on the first line of input (in this case 6) stands for the number of numbers to follow i.e., number of test cases.

Then there are T lines, each containing exactly one positive integer number N (1 <= N <= 1000000000) .

Now you need to output the total number of 0’s at occurring at the end of each N i.e., for each test cases.

Sample Input:

6 ( this is the value of T)

3 (this and the following are values of N)

60

100

1024

23456

8735373

Sample Output:

0 ( factorial of 3 = 6, so there are no trailing 0’s at the end , so answer for this case is 0)

14 ( factorial of 60 has 14 (fourteen) 0’s at the end and similarly calculate for the rest)

24

253

5861

2183837

You can check the editorial explanation for further information here .

@snowpeak :

Refer the below wikipedia link given… it is the best source and helps u in understanding all the concepts related to your question

In mathematics, trailing zeros are a sequence of 0 in the decimal representation (or more generally, in any positional representation) of a number, after which no other digits follow.
Trailing zeros to the right of a decimal point, as in 12.3400, do not affect the value of a number and may be omitted if all that is of interest is its numerical value. This is true even if the zeros recur infinitely. For example, in pharmacy, trailing zeros are omitted from dose values to prevent misreading. Howev...

1 Like