Despite having the correct logic I am not getting output? What am I doing wrong?
int main()
{
long long int count=0,i,T,n;
cin>>T;
while(T–)
{
cin>>n;
count=0;
for(i=5;n/i>=1;i=i*5)
{
count+=n/i;
}
cout<<count;
}
return 0;
}
Despite having the correct logic I am not getting output? What am I doing wrong?
int main()
{
long long int count=0,i,T,n;
cin>>T;
while(T–)
{
cin>>n;
count=0;
for(i=5;n/i>=1;i=i*5)
{
count+=n/i;
}
cout<<count;
}
return 0;
}
Your approach is correct, you just need to print each result in a new line.
For example : cout<< count<< endl; //add something here for new line feed like endl
See the same code accepted when printed in a new line here.