Trailling zero problem

i wrote my program with my own logic
#include
#include
using namespace std;

int caltrailingzeroes(int n){
int power=0;
int sum=0;
int i=1;
do{
sum=n/pow(5,i);
power=power+sum;
i++;

} while(sum!=0);
return power;

}

int main(){

int n;
cin>>n;
caltrailingzeroes(n);
cout<<caltrailingzeroes(n)<<endl;


return 0;

}
it was giving output fine but in hackerblock it is showing TLE,
so i wrote the same program in hackerblock which is in sir vedio it is only sucessful for 1 case in other casses it is showing error
#include

using namespace std;

int Findzeroes(int n){
int ans=0;
for(int d=5;d/n>=1;d=d*5){
ans=ans+n/d;
}
return ans;
}
int main () {

long long int n;
cin>>n;


cout<<Findzeroes(n)<<endl;
return 0;

}

hello @amar312696

pls save ur code at cb ide and share its link with me

it looks fine, where r u submitting? pls share its link with me

ss

also it is passing all cases

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.