标签:rgs ring cheng print [] pre str 输出 ...
package com.xuyigang1234.chp01; //1!+2!+3!+....+10!的和 public class Demo5 { public static void main(String[] args) { int sum =0; //和初始化值 for(int i=1;i<11;i++) { int jieCheng=1; //阶乘初始化值 for(int j=1;j<=i;j++) { jieCheng*=j; } sum+=jieCheng; } System.out.println("1!+2!+3!+....+10!的和为: "+ sum); } }
输出为:1!+2!+3!+....+10!的和为: 4037913
标签:rgs ring cheng print [] pre str 输出 ...
原文地址:https://www.cnblogs.com/xyg-zyx/p/9775557.html