1000的阶乘的JAVA实现

code format="java" package code;

public class SB {

/**	 * @param args */	public static void main(String[] args) { // TODO Auto-generated method stub

System.out.println; int[] a = get(1000); for (int i = 0; i < a.length; i++) { System.out.print(a[i]); if (i % 30 == 0) System.out.println; }	}

static int[] get(int n) { double a = 0; for (int j = 1; j < n; j++) a += Math.log10((double) j);

int ab = (int) a;		int[] aa = new int[ab+1]; aa[ab] = 1; for (int j = 1; j <= n; j++) {

for (int i = ab; i >=0; i--) { aa[i] = aa[i] * j;

}			for (int i = ab; i > 0; i--) { aa[i - 1] += aa[i] / 10; aa[i] = aa[i] % 10; }		}		return aa; }

}

code