package kehouzuoye28_1;
import java.util.Scanner;
/*
* 5!用递归的方法解决
*/
public class JieChengDemo {
private static Scanner sc;
public static void main(String[] args) {
sc = new Scanner(System.in);
System.out.println("请输入数字:");
int i = sc.nextInt();
System.out.println(jieCheng(i));
}
public static int jieCheng(int n){
if(n==1){
return 1;
}else{
return n*jieCheng(n-1);
}
}
}
|
|