求5的阶乘
创建一个方法求阶乘数值5可以更改为其他数值,如10或者100等。
public class one { public static void main(String[] args) { int retvalue = jiecheng(5) ; //接受返回值 System.out.println(retvalue) ; //输出结果 } //创建阶乘循环方法 public static int jiecheng(int n){ int result = 1; for(int i = n; i>1; i--){ result*=i;//累乘 } return result;//返回阶乘结果 }}``` 99413821