java写出递归并完善

public class Test{

   public static void main(String[] args){

     System.out.println(method(5));          

 }

public static int method(int n){

   if n<=1                                                 //  原代码为n==1 经改正应为 n<=1 

     return 1;

  else 

    return n*method(n-1);

}

 

}

posted @ 2019-03-17 22:22  在路上0302  阅读(106)  评论(0编辑  收藏  举报