练习4

// Factorial.cpp : Defines the entry point for the console application.
/*

data:2013/10/05

auth:ljz

func:

n!的递归实现

*/

#include "stdafx.h"
#include "iostream"
using namespace std;
int Factorial(int n)
{
if (n==1)
{
return 1;
}
else
{
return n*Factorial(n-1);
}
}

int main(int argc, char* argv[])
{
int a =0;
cin>>a;
cout<<Factorial(a)<<endl;
return 0;
}

 

你可能感兴趣的:(练习4)