Please help me to find the problem in my code

This is the first time I’m solving a problem on codechef.
I was solving FCTRL problem where you need to return trailing zeros. Following is my approach. Though I was getting expected output on submission it says wrong answer. Please tell me what’s wrong with this code.

#include <math.h>
using namespace std;

int trailing_zeros(int n){
int temp=n, result=0, i=1;
while(pow(5, i)<n){
result= result+(n/pow(5, i));
return result;

int main() {
int T, N;
for(int t=T; t>0; t–){
return 0;

1 Like

Condition should be pow(5,i)<=n.

P.S Avoid using the pow() function whenever you can.