Promi_38

number of trailing zeroes in Factorial of n

Jan 11th, 2021
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.21 KB | None | 0 0
  1. //Ex: There are 2 trailing zeroes in 10!
  2.  
  3. #include<stdio.h>
  4.  
  5. int main()
  6. {
  7.     long long n;
  8.     scanf("%lld", &n);
  9.    
  10.     long long s = 0;
  11.     while(n >= 5)
  12.     {
  13.         s += n / 5;
  14.         n /= 5;
  15.     }
  16.     printf("%lld\n", s);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment