trailing zeroes depends on no. of 5's and 2's .
total=no. of 5's.
#include <iostream>
using namespace std;
int main()
{
int a=trailingZeroes(12);
cout<<a;
}
int trailingZeroes(int A) {
int count=0;
while(A>=5)
{
count=count+A/5;
A=A/5;
}
return count;
}
total=no. of 5's.
#include <iostream>
using namespace std;
int main()
{
int a=trailingZeroes(12);
cout<<a;
}
int trailingZeroes(int A) {
int count=0;
while(A>=5)
{
count=count+A/5;
A=A/5;
}
return count;
}
No comments:
Post a Comment