Tutorials, Free Online Tutorials,It Challengers provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, core java, sql, php, c language etc. for beginners and professionals.

Breaking

11. Find the factorial of number

  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