From 442a49ad5a48d417345959b903ae6a6d32d55759 Mon Sep 17 00:00:00 2001 From: Haidong Ji Date: Fri, 15 Apr 2022 15:51:30 -0500 Subject: Great C programming fun Excellent fundamentals and displine training, many tools and techniques exercises: gdb, emacs, valgrind, git --- 23_power_rec/power.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 23_power_rec/power.c (limited to '23_power_rec/power.c') diff --git a/23_power_rec/power.c b/23_power_rec/power.c new file mode 100644 index 0000000..6be0c74 --- /dev/null +++ b/23_power_rec/power.c @@ -0,0 +1,12 @@ +#include +#include + +unsigned power(unsigned x, unsigned y) { + if (y == 0) { + return 1; + } + if (y == 1) { + return x; + } + return x * power(x, y-1); +} -- cgit v1.2.3