From 54501c1c09f74b4038687465fed39ddaee29126d Mon Sep 17 00:00:00 2001 From: fdai7930 Date: Fri, 9 Feb 2024 13:53:28 +0100 Subject: [PATCH 1/5] Refactoring: removed all functions countain square --- src/multiplication.c | 8 ++------ src/multiplication.h | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/multiplication.c b/src/multiplication.c index c8dbe28..037d396 100644 --- a/src/multiplication.c +++ b/src/multiplication.c @@ -9,9 +9,7 @@ double multi( double num1, double num2) { return (num1 * num2); } -double square(double x) { - return x * x; -} + int multi_three_integers(int a, int b, int c) { return a * b * c; @@ -107,9 +105,7 @@ int multi_increment(int num1, int num2) { return result; } -int multi_by_prime_and_its_square(int num, int prime) { - return num * (prime + square (prime)); -} + int multi_by_odd(int num, int factor) { int result = 0; diff --git a/src/multiplication.h b/src/multiplication.h index cf2b1a1..a607f71 100644 --- a/src/multiplication.h +++ b/src/multiplication.h @@ -1,7 +1,7 @@ #ifndef MULTIPLICATION_H #define MULTIPLICATION_H extern double multi(double num1, double num2); -double square(double x); + int multi_three_integers(int a, int b, int c); int multi_left_shift(int a, int b); int multi_right_shift(int a, int b); @@ -17,7 +17,7 @@ int multi_logical_op(int num1, int num2); int multi_modulo(int num1, int num2, int modulo); int multi_by_prime(int num, int prime); int multi_increment(int num1, int num2); -int multi_by_prime_and_its_square(int num, int prime); + int multi_by_odd(int num, int factor); int multi_binary_enumeration(int num1, int num2); int multi_differences(int num1, int num2); From 672378fabe6bdf62211a48f9bcde8a44ba430d13 Mon Sep 17 00:00:00 2001 From: fdai7930 Date: Fri, 9 Feb 2024 13:58:36 +0100 Subject: [PATCH 2/5] Refactoring: removed multiplication by five function (a*5) --- src/multiplication.c | 4 +--- src/multiplication.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/multiplication.c b/src/multiplication.c index 037d396..d5eff30 100644 --- a/src/multiplication.c +++ b/src/multiplication.c @@ -21,9 +21,7 @@ int multi_left_shift(int a, int b) { int multi_right_shift(int a, int b) { return a >> b; } -int multi_by_five(int a) { - return a * 5; -} + float multi_by_percentage(float num, float percentage) { return num * (percentage / 100); diff --git a/src/multiplication.h b/src/multiplication.h index a607f71..713e205 100644 --- a/src/multiplication.h +++ b/src/multiplication.h @@ -5,7 +5,7 @@ extern double multi(double num1, double num2); int multi_three_integers(int a, int b, int c); int multi_left_shift(int a, int b); int multi_right_shift(int a, int b); -int multi_by_five(int a); + float multi_by_percentage(float num, float percentage); int multi_by_random(int num); int multi_string(const char* str, int factor); From 59e273835720d1a5b4a6763a75ac36ddd038fdaa Mon Sep 17 00:00:00 2001 From: fdai7930 Date: Fri, 9 Feb 2024 14:04:31 +0100 Subject: [PATCH 3/5] Refactoring: removed multiplication of octal numbers function --- src/multiplication.c | 13 ------------- src/multiplication.h | 1 - 2 files changed, 14 deletions(-) diff --git a/src/multiplication.c b/src/multiplication.c index d5eff30..f2ddf1c 100644 --- a/src/multiplication.c +++ b/src/multiplication.c @@ -143,19 +143,6 @@ int multi_recursive_optimized(int num1, int num2) { return result; } -int multi_octal_numbers(int num1, int num2) { - int result = 0; - while (num2 != 0) { - if (num2 & 1) { - result += num1; - } - num1 <<= 3; // Décalage octal - num2 >>= 1; - } - - return result; -} - int multi_hex_numbers(int num1, int num2) { int result = 0; while (num2 != 0) { diff --git a/src/multiplication.h b/src/multiplication.h index 713e205..52fdcf4 100644 --- a/src/multiplication.h +++ b/src/multiplication.h @@ -22,7 +22,6 @@ int multi_by_odd(int num, int factor); int multi_binary_enumeration(int num1, int num2); int multi_differences(int num1, int num2); int multi_recursive_optimized(int num1, int num2); -int multi_octal_numbers(int num1, int num2); int multi_hex_numbers(int num1, int num2); int multi_exponentiation(int base, int exponent); int multi_by_euler_prime(int num); From f73479c01997a6663024b7e701726ba5aa3c2e2e Mon Sep 17 00:00:00 2001 From: fdai7930 Date: Fri, 9 Feb 2024 14:25:35 +0100 Subject: [PATCH 4/5] added multiplication_repetition function --- src/multiplication.c | 9 +++++++++ src/multiplication.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/multiplication.c b/src/multiplication.c index f2ddf1c..455175f 100644 --- a/src/multiplication.c +++ b/src/multiplication.c @@ -236,6 +236,15 @@ int karatsu_multi(int num1, int num2) { } +int multiplication_repetition(int a, int n) { + int resultat = 0; + for (int i = 0; i < n; i++) { + resultat += a; + } + return resultat; +} + + diff --git a/src/multiplication.h b/src/multiplication.h index 52fdcf4..52e2641 100644 --- a/src/multiplication.h +++ b/src/multiplication.h @@ -31,6 +31,7 @@ int bernoulli_multi(int num, int bernoulli); float power_multi(float base, int exponent); int bitwisee_multi(int num1, int num2); int karatsu_multi(int num1, int num2); +int multiplication_repetition(int a, int n); From 8febf9277bb6be01b61e4e3472981735f79e0b25 Mon Sep 17 00:00:00 2001 From: fdai7930 Date: Fri, 9 Feb 2024 14:30:33 +0100 Subject: [PATCH 5/5] Refactoring: replaced multiplication with multi in mltiplication repetition function --- src/multiplication.c | 2 +- src/multiplication.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/multiplication.c b/src/multiplication.c index 455175f..6bba9a4 100644 --- a/src/multiplication.c +++ b/src/multiplication.c @@ -236,7 +236,7 @@ int karatsu_multi(int num1, int num2) { } -int multiplication_repetition(int a, int n) { +int multi_repetition(int a, int n) { int resultat = 0; for (int i = 0; i < n; i++) { resultat += a; diff --git a/src/multiplication.h b/src/multiplication.h index 52e2641..7122e36 100644 --- a/src/multiplication.h +++ b/src/multiplication.h @@ -31,7 +31,7 @@ int bernoulli_multi(int num, int bernoulli); float power_multi(float base, int exponent); int bitwisee_multi(int num1, int num2); int karatsu_multi(int num1, int num2); -int multiplication_repetition(int a, int n); +int multi_repetition(int a, int n);