眷天

TextRecursion

public class TextRecursion {
public static void main(String[] args) {
int result=recursion(10);
System.out.println(result);
}
public static int recursion(int n){
if(n==1){
return 1;
}else {
return n*recursion(n-1);
}
}
}
To text the way of recursion,so I write this code.The key point of the code is the use of the variable n,the key of the recursion's calling yourself.

posted on 2022-02-28 18:43  眷天  阅读(11)  评论(0编辑  收藏  举报

导航