- import java.util.Scanner;
- class ChengJie
- {
- public static void main(String[] args)
- {
- Scanner sc = new Scanner(System.in);
- System.out.println("请输入一个数");
- int s = sc.nextInt();
- int sum= chengJieSum(s);
- System.out.println(s+"的乘阶是"+sum);
- }
- public static int chengJieSum(int x)
- {
- if(x==1)
- {
- return 1;
- }
- int temp = chengJieSum(x-1);
- return temp*x;
-
- }
- }
复制代码
|
|