Skip to content

Latest commit

 

History

History
26 lines (23 loc) · 241 Bytes

26.md

File metadata and controls

26 lines (23 loc) · 241 Bytes

题目:利用递归方法求5!。

#include<stdio.h>

int f(int num)
{
	int sum;
	if (num == 1)
	{
		sum = 1;
	}
	else
	{
		sum = num * f(num - 1);
	}
	return sum;
}

int main()
{
	int num = 5;
	printf("%d", f(num));

	return 0;
}