阶乘

package com.zxj.method;

public class MainClass4 {

	public static void main(String[] args) {
		for(int counter=0;counter<=10;counter++) {
			System.out.println(counter+"! = "+factorial(counter));
		}
	}
	
	public static long factorial(long number) {
		if(number<=1) {
			return 1;
		}else {
			return number*factorial(number-1);
		}
	}
}

你可能感兴趣的:(Java)