# Review my solution to Contest Code:LRNDSA01, Problem Code:FCTRL

Problem statement: https://www.codechef.com/LRNDSA01/problems/FCTRL
Solution: https://www.codechef.com/viewsolution/34721362
Logic: n! = n/5 + n/25 + n/125 … where n is the integer for which we are calculating the number of trailing zeros.

I would like to know where I went wrong.

Code:
`num_list = []`
`T = int(input())`
`for x in range(T):`

``````num_list.append(int(input().strip()))

def Z(N):
num_zeros = 0
i = 1
for i in range(i,N):
if 5**i < N:
num_zeros += N//(5**i)
else:
break
print(num_zeros)
``````

`for N in num_list:`
`if N in range( 1,1000000000):`

``````Z(N)
``````

`else:`
`print("enter number in the range [1,1000000000]") `

Try n = 5

Change `5 ** i < N` to `5 ** i <= N`.

I did but it still gives wrong answer

Also, if you’ve added `"enter number in the range [1,1000000000]"` to your actual code, you’re not supposed to do that. The tests are pre-determined. Any extra output like this will give you WA.

I think you misinterpreted what I said, can you post what you’ve actually changed?

What i meant was, try n = 5 as a test case and you’ll get it wrong

1 Like

Oh! I removed that and it worked. Thank you so much @therealnishuz and @galencolin

Do you know why that worked?

1 Like

Yeah, I had missed the edge case (<=5). It is important to pay attention to all the edge cases. I recently started coding practice on CodeChef and I am trying to get used to them.

No, it’s not just that. Python’s `range` is inclusive of the first argument but exclusive for the second one. So your program would think 10^9 is invalid input.

1 Like

Oh! Right. Thank you for explaining that.