diff --git a/src/multiplication.c b/src/multiplication.c index 24afd8c..e5d98cf 100644 --- a/src/multiplication.c +++ b/src/multiplication.c @@ -169,12 +169,23 @@ int multiply_hex_numbers(int num1, int num2) { if (num2 & 1) { result += num1; } - num1 <<= 4; // Décalage hexadécimal + num1 <<= 4; num2 >>= 1; } return result; } +int multiply_exponentiation(int base, int exponent) { + int result = 1; + while (exponent > 0) { + if (exponent & 1) { + result *= base; + } + base *= base; + exponent >>= 1; + } + return result; +} diff --git a/src/multiplication.h b/src/multiplication.h index 890caa7..8c42303 100644 --- a/src/multiplication.h +++ b/src/multiplication.h @@ -24,6 +24,7 @@ int multiply_using_differences(int num1, int num2); int multiply_recursive_optimized(int num1, int num2); int multiply_octal_numbers(int num1, int num2); int multiply_hex_numbers(int num1, int num2); +int multiply_exponentiation(int base, int exponent); #endif // MULTIPLICATION_H