11. Find the factorial of number
int Factorial( int Num )
{
If ( num > 0 ) return Num * Factorial ( Num –1 );
else
return 1;
}
// iterative version
int Factorial( int Num )
{
int I
int result = 1;
for ( I= Num; I > 0; I-- )
{
result = result * I;
}
return result;
}
No comments:
Post a Comment