Program that determines the number of trailing zeros at the end of X! (X factorial), where X is an arbitrary number.

<br />#include<iostream>
using namespace std;
int main()
{
long long a,b=1;
cout<<“Enter the number whose factorial you want to calculate=”;
cin>>a;
if(a==0)
{
cout<<endl<<“The factorial of the given number is=1″<<endl;
}
else
{

while(a>1)
{
b=b*a;
a–;
}

}
cout<<“The factorial of the given number is=”<<b<<endl;
a=0;
while(1)
{
if(b%10==0)
{
b=b/10;
a++;
}
else
{
break;
}
}
cout<<“The number of the trailing zeroes in the given factorial is=”<<a;
return 0;
}

Leave a comment