aboutsummaryrefslogtreecommitdiff
path: root/src/lib/math.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/math.c')
-rw-r--r--src/lib/math.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/math.c b/src/lib/math.c
new file mode 100644
index 0000000..9cd9cea
--- /dev/null
+++ b/src/lib/math.c
@@ -0,0 +1,15 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
+int pow(int base, int exp)
+{
+ if (exp < 0)
+ return 0;
+
+ if (!exp)
+ return 1;
+
+ int ret = base;
+ for (int i = 1; i < exp; i++)
+ ret *= base;
+ return ret;
+}