当前位置:网站首页>2.6 finding the sum of the first n terms of factorial sequence
2.6 finding the sum of the first n terms of factorial sequence
2022-06-25 19:57:00 【Then peace and happiness】
Programming , Calculation sequence 1!+2!+3!+⋯ Before N Sum of items .
Input format :
The input gives no more than 12 The positive integer N.
Output format :
Output integer results on one line .
sample input :
5
sample output :
153
Reference code :
#include<stdio.h>
#include<math.h>
double fact(int n);
int main(void)
{
int i,N;
double sum=0;
scanf("%d",&N);
for(i = 1;i <= N;i++){
sum =sum + fact(i);
}
printf("%.0f",sum);
return 0;
}
double fact(int n)
{
int i;
double product = 1;
for(i = 1; i <= n; i++){
product = product * i;
}
return product;
}
边栏推荐
- Life cycle function of composite API
- PHP Chinese regular
- JS asynchronism (III. usage of generator and async/await)
- 二、HikariCP获取连接流程源码分析二
- Arduino read temperature
- LNMP compilation and installation
- Case: count the most characters and times
- Web container basic configuration
- Go language installation and uninstallation
- wooyun-2014-065513
猜你喜欢
Record Baidu search optimization thinking analysis
Mqtt+ardunio+esp8266 development (excluding mqtt server deployment)
2020-12-09 laravel . Env file loading mechanism process
Using flex to implement the Holy Grail layout is as simple as that
Embark on a new journey and reach the world with wisdom
PHP synchronizes website content to hundreds of websites to improve SEO ranking
Uni app through uni Navigateto failed to pass parameter (pass object)
DARKHOLE 2
Use of serialize() and serializearray() methods for form data serialization
Paddleocr learning (II) paddleocr detection model training
随机推荐
Arduino : No such file or directory
Randomly generate 100 non repeating numbers between 1 and 150 and put them in the array
Profile path and name
The functions in the applet page are better than those in app JS first execution solution
Is it safe to open a new bond account
Network security detection and prevention test questions (I)
Many varieties of EA can be used
Number of wechat applet custom input boxes
Lilda Bluetooth air conditioning receiver helps create a more comfortable road life
PostgreSQL change table owner
2、 Hikaricp source code analysis of connection acquisition process II
LNMP compilation and installation
Error record: preg_ match(): Compilation failed: range out of order in character class at offset 13
二、HikariCP獲取連接流程源碼分析二
Can the stock account opened through qiniu school be used? Is the fund safe?
PHP little knowledge record
打新债证券开户安全吗
Database data type design (the most detailed in the whole network)
Applet Click to return to the top 2 methods
Tcp/ip test questions (V)