summaryrefslogtreecommitdiff
path: root/graphs/piscine/my_pow/my_pow.c
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
commitc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch)
tree3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/piscine/my_pow/my_pow.c
add: graphs et rushs
Diffstat (limited to 'graphs/piscine/my_pow/my_pow.c')
-rw-r--r--graphs/piscine/my_pow/my_pow.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/graphs/piscine/my_pow/my_pow.c b/graphs/piscine/my_pow/my_pow.c
new file mode 100644
index 0000000..f529d87
--- /dev/null
+++ b/graphs/piscine/my_pow/my_pow.c
@@ -0,0 +1,13 @@
+int my_pow(int a, int b)
+{
+ if (!a)
+ return b == 0;
+ int res = 1;
+ for (int i = 0; i < b / 2; i++)
+ {
+ res *= a * a;
+ }
+ if (b % 2)
+ res *= a;
+ return res;
+}