
/** |
* 求阶乘 |
*/ |
public class Demo { |
public static int factorial(int num) { |
int result = 1; |
if (num > 0) { |
result = num * factorial(num - 1); |
} |
return result; |
} |
public static void main(String[] args) { |
System.out.println(factorial(3)); |
} |
} |



