⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 factorial.java

📁 介绍了java的一些应用
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package 计算阶乘之和;import java.io.*;/** * * @author liuwei */public class Factorial {    private int N;    private long sum;    public Factorial(int n)    {        N=n;        sum=0;    }    public static void main(String[] args)    {        Factorial fac=new Factorial(1);//N赋初值为1        int i;        int tem=1;        System.out.println("Please input the max number N:");        try{BufferedReader br=                    new BufferedReader (new InputStreamReader(System.in));            fac.N=Integer.parseInt(br.readLine());            }catch(IOException e){}        for(i=1;i<=fac.N;i++){            tem*=i;            fac.sum+=tem;        }        System.out.println("1!+2!+…..+"+fac.N+"!=:"+fac.sum);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -