求一个数的阶乘

public class RecursiveAlgorithm {

	public static void main(String[] args) {
		System.out.println(factorial(5));
	}

	private static int factorial(int num) {
		if (num == 1)
			return 1;
		return factorial(num - 1) * num;
	}
}

你可能感兴趣的:(求一个数的阶乘)