From 21d537ed76f47de17348ab97aacf5299a19ceff9 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Sun, 13 Mar 2022 21:48:02 +0100 Subject: [PATCH] Useless square function? --- lib/math.c | 9 +++++++++ lib/math.h | 1 + 2 files changed, 10 insertions(+) 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);