public static int fac(int num){
if(num == 1){
return 1;
}
return num * fac(num-1);
}
public static void main(String[] args) {
int n = 5;
System.out.println("result = " + fac(n));
}
08-16
338
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-16
829
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-06