> 其他 >
用java编写一个程序,计算1!+2!+3!+4!+5!
人气:359 ℃ 时间:2020-01-26 11:00:25
解答
public class TestArray{public static void main(String[] args){int m = 0;for(int i = 1;i < 6;i++){int n = 1;for(int j = 1;j < i+1;j++){n = n * j;}m = m + n;}System.out.println(m);}}运行结果:153
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版