IT Placement Papers Programming DataStructure
This category contains DataStructure Interview Questions and Answers |
Find the factorial of number
|
|
|
|
|
// // recursive version //
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; }
Only registered users can write comments. Please login or register.
|