当前位置:网站首页>C语言:递归实现N的阶乘
C语言:递归实现N的阶乘
2022-06-23 22:24:00 【念迟鱼学编程】
#include <stdio.h>
long f(int x);
int main()
{
int a;
printf("请输入要计算阶乘的数:");
scanf("%d",&a);
printf("%d的阶乘为:%d\n",a,f(a));
return 0;
}
long f(int x)
{
long g;
if(x<0){
printf("x<0,输入有误!");
}
else if(x==1 || x==0){
g = 1;
}else{
g = x*f(x-1);
}
return g;
}
边栏推荐
- Synthetic big watermelon games wechat applet source code / wechat game applet source code
- SAVE: 软件分析验证和测试平台
- Android App bundle exploration, client development interview questions
- 纯js实现判断ip是否ping通
- Usage of go in SQL Server
- Android 3年外包工面试笔记,有机会还是要去大厂学习提升,android开发实习面试题
- == 和 equals 的区别是什么?
- Leetcode - linked list written test questions
- Quantitative investment model -- research interpretation of high frequency trading market making model (Avellaneda & Stoikov's) & code resources
- How to use data warehouse to create time series
猜你喜欢

UART协议时序总结

EasyCVR程序以服务启动异常,进程启动却正常,是什么原因?
![[interview experience package] summary of experience of being hanged during interview (I)](/img/ab/ccee8e624248840e712c0b4ca417dd.png)
[interview experience package] summary of experience of being hanged during interview (I)

Docker deploy redis

DO280OpenShift访问控制--管理项目和账户

抖音实战~密码找回

CPU取指到发出控制、微程序控制原理详细过程

Six necessary open source projects for private activities

【图像检测显著图】基于matlab失真提示鱼眼图显著图计算【含Matlab源码 1903期】
![Restore IP address [standard backtracking + standard pruning]](/img/e6/5f9d2a5af973b6c7051ed434a4b93d.png)
Restore IP address [standard backtracking + standard pruning]
随机推荐
Principles and differences between hash and history
Do280openshift access control -- manage projects and accounts
== 和 equals 的区别是什么?
Vulnerability recurrence - redis vulnerability summary
fatal: The upstream branch of your current branch does not match the name of your current branch.
【FreeRTOS】07 二值信号量、计数信号量
Revit API:明细表 ViewSchedule
WPF效果之Expander+ListBox
Save: software analysis, verification and test platform
Six complete open source projects, learning enough at a time
依赖倒置原则
kubernetes之常用核心资源对象
Android 7,2021最新Android面试笔试题目分享
How to get started with machine learning?
Docker Deployment redis
Detailed process from CPU fetching to sending control and microprogram control principle
Facebook open source shimmer effect
Android 72021 latest Android interview written test questions sharing
Confused test / development programmers, different people have different stories and different puzzles
Jimureport building block report - table linkage chart topic