LyWang

trailingZero

Nov 18th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     /*
  4.      * @param n: A long integer
  5.      * @return: An integer, denote the number of trailing zeros in n!
  6.      */
  7.    
  8. long long trailingZeros(long long n) {
  9.     long long counter=0;
  10.     while (n!=0) {
  11.         n /= 5;
  12.         counter +=  n;
  13.     }
  14.     return counter;
  15. }
  16.  
  17. };
Add Comment
Please, Sign In to add comment