当前位置:网站首页>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;
}
边栏推荐
- Shutter time selector
- Easycvr implementation of adding preset point position function of Dahua equipment
- Hackers can gain administrator privileges by invading Microsoft mail server and windows Zero Day vulnerability November 23 global network security hotspot
- How to use data warehouse to create time series
- docker 部署redis
- 微信小程序中three.js的canvas非全屏情况下射线检测不准确问题解决方案
- UART protocol timing summary
- Superscalar processor design yaoyongbin Chapter 3 virtual memory -- Excerpt from subsection 3.1~3.2
- [technical grass planting] the tail of the "double 11" event. Let's talk about how much discount the message push service package is!
- 小猫爪:PMSM之FOC控制15-MRAS法
猜你喜欢

docker 部署redis
![[traffic light identification] traffic light identification based on Matlab GUI [including Matlab source code 1908]](/img/0e/3103c4c5dd664196c85db9b30bcaf5.png)
[traffic light identification] traffic light identification based on Matlab GUI [including Matlab source code 1908]

Dependency Inversion Principle

Quantitative investment model -- research interpretation of high frequency trading market making model (Avellaneda & Stoikov's) & code resources

解决项目依赖报红问题

Cloud native architecture (05) - Application Architecture Evolution

Do280openshift access control -- manage projects and accounts

Solve the problem of project dependency red reporting

The easycvr program started abnormally as a service, but the process started normally. What is the reason?

Facebook open source shimmer effect
随机推荐
Wechat applet picture verification code display
Six necessary open source projects for private activities
AI技术在医学领域有什么用?
微信小程序中three.js的canvas非全屏情况下射线检测不准确问题解决方案
[image detection saliency map] calculation of fish eye saliency map based on MATLAB distortion prompt [including Matlab source code 1903]
如何利用数仓创建时序表
超标量处理器设计 姚永斌 第3章 虚拟存储器 --3.1~3.2 小节摘录
[digital signal] spectrum refinement based on MATLAB analog window function [including Matlab source code 1906]
迷茫的测试/开发程序员,不同人有着不同的故事、有着不同的迷茫......
Superscalar processor design yaoyongbin Chapter 3 virtual memory -- Excerpt from subsection 3.1~3.2
C语言c89(c90)的所有的32个关键字分类
String s = new string ("XYZ") how many string objects are created?
Salesforce batch apex batch processing (V) asyncapexjob intelligence
Shuttle global levitation button
Tiktok practice ~ password retrieval
元宇宙中的社会秩序
[traffic light identification] traffic light identification based on Matlab GUI [including Matlab source code 1908]
What is medical treatment? AI medical concept analysis AI
Another short video app with high imitation and eye opening
Total number of combinations ii[each element can only be solved by + once]