当前位置:网站首页>C语言:数的阶乘递归实现
C语言:数的阶乘递归实现
2022-07-15 17:59:00 【念迟鱼学编程】
下面的实例使用递归函数计算一个给定的数的阶乘:
#include <stdio.h>
double factorial(unsigned int i)
{
if(i <= 1)
{
return 1;
}
return i * factorial(i - 1);
}
int main()
{
int i = 15;
printf("%d 的阶乘为 %f\n", i, factorial(i));
return 0;
}
当上面的代码被编译和执行时,它会产生下列结果:
15 的阶乘为 1307674368000.000000
边栏推荐
- Consumer start flash back
- 8254 timer / counter application experiment
- Is it safe to open an account online now? Want to know which are the top ten securities dealers in China?
- SAP ABAP 系统进行数据库表查询的几种常用方法的试读版
- 一文搞懂│什么是跨域?如何解决跨域?
- Vscode default new directory overlap
- 在 SQL Server 中查找活动的 SQL 连接
- C# Channel 简单实现消息队列的发布、订阅
- BigDecimal compare size
- Tens of billions of data were compressed to 600gb, and tdengine was launched on GCL energy mobile energy platform
猜你喜欢

数百亿数据压缩至 600GB,TDengine 落地协鑫能科移动能源平台

Des dizaines de milliards de données compressées à 600 go, tdengine est installé sur la plateforme mobile d'énergie de GCL

Opengauss cooperates with industry innovation to build a root community of open source databases

GeoServer完整教程

Unity iotar augmented reality tutorial

Torch in pytoch Analysis of nonzero() function

Li Mu hands on deep learning V2 target detection SSD

Daily question · 1217 Playing chips · greed

Torch in pytoch Unsqueeze() and torch Squeeze() function parsing

745. Prefix and suffix search
随机推荐
Pytoch distributed training
A hot pot restaurant has collected three IPOs
Swift value type and reference type
Is the sub database and sub table really suitable for your system? Talk about how to select sub databases, sub tables and newsql
中金财富证券是正规证券公司吗?开户安全吗
umask计算创建文件、目录的默认权限
@Repository @ [email protected] Understanding of annotations
676. Implement a magic dictionary prefix tree
One question per day · 648 Word replacement · prefix tree
Software architecture and design (IV) -- data flow architecture
337.打家劫舍·动态规划
337. Looting · dynamic planning
Torch in pytoch Analysis of nonzero() function
GeoServer完整教程
R language uses the melt function of reshape2 package to transform dataframe data from wide table to long table, and dcast function processes the data processed by melt function from long table to wid
406 · rebuild the queue according to height · greed
Data transmission: Practice of batch extraction of isomorphic and heterogeneous IP data sources
Software architecture and design (II) -- Architecture Model
对接企业微信,客户关系管理也可以很简单!
家居建材企业如何打造智慧供应链管理体系?数商云供应链系统深耕采购、物流多业务应用场景