标签:OLE split solution lse trail count spl int bool
示例 1:
输入: 3 输出: 0 解释: 3! = 6, 尾数中没有零。
示例 2:
输入: 5 输出: 1 解释: 5! = 120, 尾数中有 1 个零.
代码部分
class Solution { public int trailingZeroes(int n) { if (n < 5) { return 0; } int count = 0; int len = n / 5; for (int i = 1; i <= len; i++) { count = count + split(5 * i); } return count; } public static int split(int n) { if (n < 5) { return 0; } int len = 0; boolean flag = true; while (flag) { if (n / 5 < 5) { flag = false; } if (n / 5 % 5 == 0) { n = n / 5; } else { flag = false; } len++; } return len; } }
标签:OLE split solution lse trail count spl int bool
原文地址:https://www.cnblogs.com/davidwang456/p/9007581.html