public class Test12 {
public static void main(String[] args) {
Test12 test = new Test12();
System.out.println(test.getResult(3));
}
public int getResult(int n){
if(n==1){
return n;}
else{
return n*getResult(n-1);}
}
}
getResult(3)中的3是随便输出正数的,输出几就是几的阶乘。