public class Test{

   public static void main(String[] args){

     System.out.println(method(5));          //   5 可以改成任何整数

 }

public static int method(int n){

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

     return 1;

  else 

    return n*method(n-1);

}

 

}

版权声明:本文为lsn0302原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/lsn0302/p/10549345.html