Factorial Trailing Zeroes

 1 class Solution {
 2 public:
 3     int trailingZeroes(int n) {
 4         int ret = 0;
 5         while(n)
 6         {
 7             ret += n/5;
 8             n /= 5;
 9         }
10         return ret;
11     }
12 };

 

posted @ 2015-06-09 10:24  阿怪123  阅读(101)  评论(0编辑  收藏  举报