递归计算N阶乘
#include "stdafx.h"
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
long Factorial(long);
void main()
{
char ch;
long n;
printf("---Factorial counting Using Recursive---");
do{
printf("\nEnter a number (0<=12) to count n! :\n");
scanf("%ld",&n);
if(n<0||n>12)
printf("input out of range!\n");
else
printf("%ld=%ld\n",n,Factorial(n));
printf("Continue(y/n)?\n");
ch=toupper(getche());
}while(ch=='y');
}
long Factorial(long n)
{
if(n==1||n==0)
return (1);
else
return (n*Factorial(n-1));
}