递归

public class Demo07 {
//递归
public static void main(String[] args) {
System.out.println(f(4));

}
//阶乘
public static int f(int n){
if(n==1){
return 1;
}else{
return n*f(n-1);
}
}

}
posted @ 2023-02-04 15:33  惊鸿宴远赴人间  阅读(17)  评论(0)    收藏  举报