import java.text.SimpleDateFormat;
import java.util.Date;
public class ImoocStudent {
public static void main(String[] args) throws Exception{
for(int counter = 0; counter <= 10;counter++){
// 这里写法:把counter,factorial() 对应放到第一个%d , 第二个%d
System.out.printf("%d! = %d\n",counter,factorial(counter));
}
}
public static long factorial(long number){
if(number <= 1)
return 1;
else
return number * factorial(number - 1);
}
}
标签:ImoocStudent,java,实现,counter,阶乘,import,public
From: https://www.cnblogs.com/pansidong/p/17433577.html