C语言:递归函数n!
2024-09-14 08:10:13
#include <stdio.h>
long recursion(int n);
void main()
{
int n;
long result;
printf("input a integer number:\n");
scanf("%d",&n);
result=recursion(n);
printf("%d!=%ld\n",n,result);
}
long recursion(int n)
{
long temp_result;
if(n<0)
{
printf("n<0,input error!\n");
}
else if(n==0 || n==1)
{
temp_result=1;
}
else
{
temp_result=recursion(n-1)*n;
}
return temp_result;
}
最新文章
- [LeetCode] Implement Queue using Stacks 用栈来实现队列
- POJ1740A New Stone Game[组合游戏]
- haproxy+keepalived实现高可用负载均衡
- C#借助谷歌翻译实现翻译小工具(二)添加托盘图标
- JdbcTemplate查询数据 三种callback之间的区别
- php里ezpdo orm框架初探
- 如何改变dreamweaver的编码方式
- Learning Web
- iOS 5 故事板入门(3)
- 3--OC -- 点语法
- element-ui对话框组件Dialog在回调事件opened获取组件滚动条scrollTop的问题
- Registrator中文文档
- 实验吧web题:
- Python基础知识:if语句
- 网页性能优化之异步加载js文件
- C# System.IO.FileAccess
- Python 字典 fromkeys()方法
- Win10无法启动软件提示MSVCP110.dll丢失
- [ZT] 医学图像分析相关的会议
- 【洛谷mNOIP模拟赛Day1】T1 斐波那契