summaryrefslogtreecommitdiff
path: root/23_power_rec/power.c
blob: 6be0c74f3391cc74f3d24df177d37c7373f2303e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
#include <stdlib.h>

unsigned power(unsigned x, unsigned y) {
  if (y == 0) {
    return 1;
  }
  if (y == 1) {
    return x;
  }
  return x * power(x, y-1);
}