当前位置:网站首页>The basis of C language grammar -- function nesting, Fibonacci sum of recursive applet and factorial
The basis of C language grammar -- function nesting, Fibonacci sum of recursive applet and factorial
2022-06-26 09:52:00 【Tanzanian auduvi Canyon expert】
long jiecheng(int num){
long result=1,i;
for(i=1;i<=num;i++){
result*=i;
}
return result;
}
long pingfang(int a){
return jiecheng(a*a);
}
int main(int argc, char *argv[]) {
// s=2 2! + 3 3! + 4 4!
int i;
long res=0;
for(i=2;i<=4;i++){
res+=pingfang(i);
}
printf("%1d",res);
return 0;
}
//*********************************************************
// 4 Recursive factorial of 4!= 1*2*3*4 = 4*3*2*1
long jiecheng(int n){
long result;
if(n<=1){
result=1;
}else{
result=n*jiecheng(n-1); //
}
return result;
}
int main(int argc, char *argv[]) {
printf("%d",jiecheng(4));
return 0;
}
//*********************************************************
// Napoch 12 and 1 1 2 3 5 8 13 21 34
int f(int n){
if(n==1 || n==2){
return 1;
}else{
return f(n-1)+f(n-2); //
}
}
int main(int argc, char *argv[]) {
int sum=0,i;
for(i=1;i<=12;i++){
sum += f(i);
}
printf("%d",sum);
return 0;
}
边栏推荐
- Champions League data set (Messi doesn't cry - leaving Barcelona may reach another peak)
- [Journal of Computer Aided Design & computer graphics] overview of research on pedestrian re recognition methods based on generated countermeasure network
- 2021年全国职业院校技能大赛(中职组)网络安全竞赛试题(2)详解
- npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.npm ER
- Introduction to QPM
- 力扣------从数组中移除最大值和最小值
- Jz2440 - - - utiliser le programme de gravure uboot
- Summary of common commands of vim
- A concise tutorial for getting started with go generics
- Several connection query methods of SQL (internal connection, external connection, full connection and joint query)
猜你喜欢

MapReduce&Yarn理论

Redis notes (13) - scan and keys search for specific prefix key fields (command format, usage examples, locating large keys)

软件测试---如何选择合适的正交表

My creation anniversary

Install new version cmake & swig & tinyspline

#云原生征文# 在 Google Kubernetes Cluster 上使用 HANA Expression Database Service

Jz2440 - - - utiliser le programme de gravure uboot

欧冠比赛数据集(梅西不哭-离开巴萨也可能再创巅峰)

Redis 新手入门

Force buckle ----- remove the maximum and minimum values from the array
随机推荐
Specific implementation comparison between different programming languages
2021-11-29 轨迹规划五次多项式
The shutter tabbar listener is called twice
Champions League data set (Messi doesn't cry - leaving Barcelona may reach another peak)
SQL 函数
Single sign on logic
Jz2440--- using uboot burning program
2021-11-12 vrep vision sensor configuration
Redis notes (16) - info instructions and command line tools (view memory, status, number of client connections, monitoring server, scan large keys, sampling server, execute batch commands, etc.)
pcl install
pcl install
c语言语法基础之——指针( 多维数组、函数、总结 ) 学习
From TF 1 X to TF 2.6 (update if you encounter it)
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. npm ER
Daily-used English phrases
Meaning of go runtime
LeetCode 基本计算器 224. 227. follow up 394
Js--- get the data with the same key value in the object array to get a new array
2021-11-22 运动规划杂记
LeetCode 接雨水系列 42.(一维) 407.(二维)