Factorial question

count=0
t=input()
def z(x):
answer=0
while(x>5):
x=x/5
answer=answer+x
return answer
while(count<t):
print z(input())
count+=1



this is my code…it gives me the correct result on ideone.com…but codechef isn’t aacepting this and says “wrong answer” although the given sample input gives the required output…please tell what to do??

can you pls upload ur code in ideone??

1 Like

it should be while( x > = 5 ).

The output will be wrong for 25, 125, 625 etc.

5 Likes

here is the running version

t=input()
def z(x):
answer=0
while(x>=5): # You are missing equals sign here
x=x/5
answer=answer+x
return answer
while(t>0):
print z(input())
t-=1
I think now you will get an AC :slight_smile:

2 Likes