Advertisement
Kali_prasad

trailing zeros of factorial

Mar 13th, 2022
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int fives(int n)
  4. {
  5.     int k=(log(n)/log(5));
  6.      //cout<<k;
  7.     return ((1-(pow(0.2,k)))/4)*n;
  8. }
  9. int main()
  10. {
  11.     int n;
  12.     cin>>n;
  13.     vector<int> v;
  14.     for(int i=0;i<n;i++)
  15.     {
  16.         int temp;
  17.         cin>>temp;
  18.         v.push_back(fives(temp));
  19.     }
  20.     for(auto x:v)
  21.     {
  22.         cout<<x<<endl;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement