/* 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); } }
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; }
int main() { printf("%d\n",powerR(3,4)); return 0; }