diff --git a/lib/math.c b/lib/math.c index bfded6f..5268663 100644 --- a/lib/math.c +++ b/lib/math.c @@ -8,3 +8,12 @@ long pow(int num, uint expon) { return prod; } + +long square(uint num) { + long sum = num - 1; + while(num > 0) { + sum += num*2; + sum--; + } + return sum + 1; +} diff --git a/lib/math.h b/lib/math.h index 1abe7e4..a68b506 100644 --- a/lib/math.h +++ b/lib/math.h @@ -1,3 +1,4 @@ #include "types.h" long pow(int, uint); +long square(int);