标签:
package com.x.xyz; public class HelloWorld { public static void main(String[] args) { System.out.println("Star !"); System.out.println(trailingZeroes(10)); System.out.println(trailingZeroes(125)); System.out.println(trailingZeroes(25)); System.out.println(trailingZeroes(3)); System.out.println(trailingZeroes(4)); System.out.println(trailingZeroes(5)); System.out.println(trailingZeroes(6)); System.out.println(trailingZeroes(7)); } public static int trailingZeroes(int n) { int x = 5; int ans = 0; while(n >= x) { ans = ans + n/x; x = x*5; } return ans; } }
172 Factorial Trailing Zeroes 过了。英文真不好读啊。
标签:
原文地址:http://blog.csdn.net/wide288/article/details/42270101