求1!+2!+...+20!的和并显示,同时输出结果

package chapter_after5;

public class Five_4 {
	public static void main(String[] args) {
		int num = 20;
		double mult, sum = 0;
		for (int i = 1; i <= num; i ++) {
			mult = 1;
			for (int j = 1; j <= i; j++) {
				mult *= j;
			}
			System.out.println( i + "的阶乘为:" + mult);
			sum += mult;
		}
		System.out.println("所有阶乘的和为" + sum);
	}
}
上一篇:react-native的技巧


下一篇:DocFetcher使用笔记