标签:
package com.x.xyz; public class HelloWorld { public static void main(String[] args) { System.out.println("Star !"); System.out.println(trailingZeroes(0)); System.out.println(trailingZeroes(1)); System.out.println(trailingZeroes(2)); 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 sum = 10; // if(0 == n) { // return 1; // } // for(int i=1; i<n; i++) { // sum = sum * 10; // } // return sum; if(0 == n) { return 1 * sum; }else{ return trailingZeroes(n-1) * sum; } } }Star !
Factorial Trailing Zeroes , 172题,可能是我没读清楚,还报错。
标签:
原文地址:http://blog.csdn.net/wide288/article/details/42269715