Exemple #1
0
/*  
   gcc -S powerR.c -std=iso9899:1999
*/
int  powerR(int pow, int base) {
  if (0==pow) {
    return 1;
  } else {
    return base * powerR(pow-1, base);
  }
}
Exemple #2
0
int main(void) {
  int ans;

  printf("\n\n");
  ans = powerI(5, 2);
  printf(" 2 to 5 is %d\n", ans);
  ans = powerI(4, 3);
  printf(" 3 to 4 is %d\n", ans);
  printf("\n");

  printf("\n\n");
  ans = powerR(5, 2);
  printf(" 2 to 5 is %d\n", ans);
  ans = powerR(4, 3);
  printf(" 3 to 4 is %d\n", ans);
  printf("\n");

  return 0;
}
Exemple #3
0
int main()
{
  printf("%d\n",powerR(3,4));
  return 0;
}