package com.wzt.www.method;
/**
* @author WZT
* @create 2021-03-26 10:56
*/
public class Demo05 {
public static void main(String[] args) {
Demo05 test = new Demo05();
Long result = test.f(33L);
System.out.println(result);
}
public Long f(Long n){
if (n==1){
return (long)1L;
}else {
return n*f(n-1);
}
}
}
输出
3400198294675128320
Process finished with exit code 0
注意点
- 递归不要太多次容易造成栈溢出