Posted on 2007-06-30 23:13
停留的风 阅读(184)
评论(0) 编辑 收藏 所属分类:
C语言学习历程
#include<stdio.h>
int main(void)
{
unsigned int j;
unsigned long int factorial(unsigned int n);
for(j=0;j<11;j++)
{
printf("%2u!=%lu\n",j,factorial(j));
}
return 0;
}
unsigned long int factorial(unsigned int n)
{
unsigned int result;
if(n==0)
{
result=1;
}
else
{
result=n*factorial(n-1);
}
return result;
}
运行结果: