![]() |
C++/CLI Example: Factorial 2 |
This program calculates the factorial of an integer: using namespace System;
long Factorial(long number)
{
if( number <= 1 )
return 1;
else
return number * Factorial(number - 1);
}
int main()
{
Console::WriteLine(L"The factorial of 5 is: {0}\n",
Factorial(5));
return 0;
}
This would produce: The factorial of 5 is: 120 Press any key to continue . . .
|
|
|
||
| Home | Copyright © 2007 FunctionX, Inc. | |
|
|
||