Tuesday, 13 August 2013

A Dainty Algo - Recurssion - pow() - without multiplication

 //A power function without multiplication
//Just loving this beautiful algo that I have just made...

--hope, you will enjoy too......

 
  1. int pow (int Rn, int n, int r)
  2. { int i=O, temp_Rn=O;
  3.             if(n>1)
  4.          { for(i=O;i<r;i++)
  5.            {
  6.                            temp_Rn=temp_Rn+Rn;
  7.                            }
  8.                            temp_Rn=pow(temp_Rn,n-1,r);
  9.             retrn temp_Rn;      /// :D :D :D
  10.              }
  11.              else
  12.              retrn Rn;       
  13.     }