Example #1
0
// Use a recursive implemention which is O(ln n) in both space and size
RINGING_LLONG ipower( int base, int exp )
{
  if (exp == 0)
    return 1;
  else if (exp < 0)
    return 0;  // inevitably rounds to zero
  else if (exp % 2)
    return base * ipower(base, exp - 1);
  else {
    RINGING_LLONG temp = ipower(base, exp / 2);
    return temp * temp;
  }
}
Example #2
0
int main(){

  Complex z;
  z.re = 1.0;
  z.im = 2.0;

  printf("%ld\n", factorial(5));
  printf("%lf \n", ipower(3,2));
  
  //print(z.re,z.im);
  printf("mag is %lf \n", magnitude(z));
  //printf("conjugate is ")
  conjugate(&z);
  print(z);

  return(0);
}
Example #3
0
 double xpower10(double p_x)
 {
     return ipower(p_x, 10);
 }