代碼code
public class ceshi { public static void main(String args[]) { int n, sum = 0; n= Integer.parseInt(args[0]); System.out.println("n(n>=0)"); for (int i = 1; i <= n; i++) { sum += fact(i); } if(n>0) System.out.println("1!+...+"+n+"!="+sum); else System.out.println("0!="+1); } public static long fact(int a) { if(a == 0) return 1; else return a*fact(a-1); } }