From 6590afc6991a49ca2622ec5f9f22f766d8c332ad Mon Sep 17 00:00:00 2001 From: fdai7930 Date: Thu, 8 Feb 2024 12:54:19 +0100 Subject: [PATCH] power multiplication fonction added --- src/multiplication.c | 10 +++++++++- src/multiplication.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/multiplication.c b/src/multiplication.c index 6a3c5a3..0734802 100644 --- a/src/multiplication.c +++ b/src/multiplication.c @@ -206,11 +206,19 @@ int repeated_division_multiply(int num1, int num2) { } return result; } - + int bernoulli_multiply(int num, int bernoulli) { return num * bernoulli; } +float power_multiply(float base, int exponent) { + float result = 1.0; + for (int i = 0; i < exponent; i++) { + result *= base; + } + return result; +} + diff --git a/src/multiplication.h b/src/multiplication.h index 97be960..c29b077 100644 --- a/src/multiplication.h +++ b/src/multiplication.h @@ -29,7 +29,7 @@ int multiply_by_euler_prime(int num); int fibonacci_multiply(int num, int fib); int repeated_division_multiply(int num1, int num2); int bernoulli_multiply(int num, int bernoulli); - +float power_multiply(float base, int exponent);