当前位置:网站首页>Finding the sum of N multiplications
Finding the sum of N multiplications
2022-06-26 01:50:00 【So it is^^】
Method 1 :
#include<stdio.h>
int main()
{
int i = 1;
int j = 1;
int sum = 0;
int cj = 0;
int n = 0;
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
int cj = 1; // Every degree of multiplication is from 1 At the beginning , So to initialize
for (j = 1; j <= i; j++)
{
cj = cj * j; // Find the multiplication order of each value
}
sum = sum + cj; // Add up the of each value
}
printf("%d", sum);
}Method 2 :
#include<stdio.h>
int main()
{
int i = 0;
int cj = 1;
int n = 0;
int sum = 0;
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
cj = cj * i; // seek 1 To n Multiplication of values
sum = sum + cj; // seek 1 To n Value the sum of each multiplier
}
printf("%d", sum);
return 0;
}边栏推荐
猜你喜欢

GUN make (2) 总述

cyclegan:unpaired image-to-image translation using cycle-consistent adversarial network

pixel 6 root

cyclegan:unpaired image-to-image translation using cycle-consistent adversarial network

清甜女孩李斯霞 受邀担任第六季完美童模全球总决赛小主持人

Energetic girl wangyujie was invited to be the spokesperson for the global finals of the sixth season perfect children's model

浅谈接口测试(二)

Redis7.0的安装步骤

Dataframe to list

Assertion of postman interface test
随机推荐
ActivityManager kill reason
Abnova丨CSV 单克隆抗体解决方案
Show spirit chenzitong was invited to be the chief experience officer of the global finals of the sixth season perfect children's model
输入3个整数,从大到小输出出来
How to add a "security lock" to the mobile office of government and enterprises?
26. histogram back projection
Cross validation -- a story that cannot be explained clearly
memory leak check tools 详解
PTA class a simulation bomb 10: 1119-1123
leetcode 300. Longest increasing subsequence (medium)
JQ 自定义属性取值
UN make (6) makefile的条件执行
微信朋友圈测试点
求n的乘阶
tos cos dscp 区别和作用
分布式系统(二)分布式事务的理解
wifi 相关知识详解
Forgotten Jieba participle
清甜女孩李斯霞 受邀担任第六季完美童模全球总决赛小主持人
俏皮少女王艺璇 受邀担任第六季完美童模全球总决赛推广大使