Auto commit

This commit is contained in:
smallkun 2025-03-18 08:37:39 +08:00
parent 152541650a
commit adb07f27c5
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,30 @@
#include <stdio.h>
//Ãݴη½
int power(int n){
int s = 1, i;
for(i=1;i<=n;i++){
s *= 2;
}
return s;
}
//½×³Ë
int factorial(int n){
int s = 1, i;
for(i=1;i<=n;i++){//1~n
s*=i;
}
return s;
}
int main(){
int n, i, s = 0;
scanf("%d", &n);
for(i=1;i<=n;i++){
s += power(i) * factorial(i);
}
printf("%d\n", s);
return 0;
}

View File

@ -702,6 +702,36 @@ int main(){
![image-20250227231154429](https://yp.smallkun.cn/markdown/image-20250227231154429.png!compress)
```c
#include <stdio.h>
//幂次方
int power(int n){
int s = 1, i;
for(i=1;i<=n;i++){
s *= 2;
}
return s;
}
//阶乘
int factorial(int n){
int s = 1, i;
for(i=1;i<=n;i++){//1~n
s*=i;
}
return s;
}
int main(){
int n, i, s = 0;
scanf("%d", &n);
for(i=1;i<=n;i++){
s += power(i) * factorial(i);
}
printf("%d\n", s);
return 0;
}
```