当前位置:网站首页>输出1!+2!+3!+......+n!
输出1!+2!+3!+......+n!
2022-08-03 14:02:00 【码起来呗】
Description:
输入一个正整数n。输出1!+2!+3!+…+n!的值。
Input:
输入一个正整数n。
Output:
输出1!+2!+3!+…+n!的值。
Sample Input:
4
Sample Output:
33
HINT
Source
public class JieChengJia {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int num=1;
int ans=0;
for (int i=1;i<=n;i++){
num=num*i;
ans+=num;
// System.out.print(num + " ");
}
// System.out.println();
System.out.print(ans);
}
}
边栏推荐
猜你喜欢
随机推荐
APT组织最喜欢的工具 Cobalt Strike (CS) 实战
中国菜刀原理与实践
162_Power Query is a custom function for quickly merging tables in a folder TableXlsxCsv_2.0
驻冰岛使馆提醒旅冰中国公民务必加强安全防护
【框架】idea找不到xxx依赖项怎么办
Relia Tech活性VEGFR重组蛋白丨小鼠 VEGF120实例展示
线程的状态
网易互娱在秒级监控、服务限流、AIOps落地上的运维升级实践
How to connect a VMware virtual machine to the network "recommended collection"
OpenHarmony高校技术俱乐部计划发布
TensorFlow离线安装包
Top 10 free proxy IP software_Domestic static IP proxy software
MSF编码与upx加壳过杀软
How to use matlab to implement the piecewise function "recommended collection"
Tao Te: Engine or baggage?
项目管理:PMP和IPMP哪个更值得考?两个证书的区别在于哪里?
进程通信的方式
Left index of all anagrams in leetcode/string (some permutation of s1 string is a substring of s2)
VMware 虚拟机如何连接网络「建议收藏」
爱可可AI前沿推介(8.3)








