Browse Source

Merge branch 'multiplication' into 'master'

Multiplication

See merge request fdai7848/Linkes-Twix!12
master
fdai7930 11 months ago
parent
commit
c803992485
  1. 34
      src/multiplication.c
  2. 8
      src/multiplication.h

34
src/multiplication.c

@ -9,9 +9,7 @@ double multi( double num1, double num2) {
return (num1 * num2); return (num1 * num2);
} }
double square(double x) {
return x * x;
}
int multi_three_integers(int a, int b, int c) { int multi_three_integers(int a, int b, int c) {
return a * b * c; return a * b * c;
@ -23,9 +21,7 @@ int multi_left_shift(int a, int b) {
int multi_right_shift(int a, int b) { int multi_right_shift(int a, int b) {
return a >> b; return a >> b;
} }
int multi_by_five(int a) {
return a * 5;
}
float multi_by_percentage(float num, float percentage) { float multi_by_percentage(float num, float percentage) {
return num * (percentage / 100); return num * (percentage / 100);
@ -107,9 +103,7 @@ int multi_increment(int num1, int num2) {
return result; 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 multi_by_odd(int num, int factor) {
int result = 0; int result = 0;
@ -149,19 +143,6 @@ int multi_recursive_optimized(int num1, int num2) {
return result; 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 multi_hex_numbers(int num1, int num2) {
int result = 0; int result = 0;
while (num2 != 0) { while (num2 != 0) {
@ -255,6 +236,15 @@ int karatsu_multi(int num1, int num2) {
} }
int multi_repetition(int a, int n) {
int resultat = 0;
for (int i = 0; i < n; i++) {
resultat += a;
}
return resultat;
}

8
src/multiplication.h

@ -1,11 +1,11 @@
#ifndef MULTIPLICATION_H #ifndef MULTIPLICATION_H
#define MULTIPLICATION_H #define MULTIPLICATION_H
extern double multi(double num1, double num2); extern double multi(double num1, double num2);
double square(double x);
int multi_three_integers(int a, int b, int c); int multi_three_integers(int a, int b, int c);
int multi_left_shift(int a, int b); int multi_left_shift(int a, int b);
int multi_right_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); float multi_by_percentage(float num, float percentage);
int multi_by_random(int num); int multi_by_random(int num);
int multi_string(const char* str, int factor); int multi_string(const char* str, int factor);
@ -17,12 +17,11 @@ int multi_logical_op(int num1, int num2);
int multi_modulo(int num1, int num2, int modulo); int multi_modulo(int num1, int num2, int modulo);
int multi_by_prime(int num, int prime); int multi_by_prime(int num, int prime);
int multi_increment(int num1, int num2); 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_by_odd(int num, int factor);
int multi_binary_enumeration(int num1, int num2); int multi_binary_enumeration(int num1, int num2);
int multi_differences(int num1, int num2); int multi_differences(int num1, int num2);
int multi_recursive_optimized(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_hex_numbers(int num1, int num2);
int multi_exponentiation(int base, int exponent); int multi_exponentiation(int base, int exponent);
int multi_by_euler_prime(int num); int multi_by_euler_prime(int num);
@ -32,6 +31,7 @@ int bernoulli_multi(int num, int bernoulli);
float power_multi(float base, int exponent); float power_multi(float base, int exponent);
int bitwisee_multi(int num1, int num2); int bitwisee_multi(int num1, int num2);
int karatsu_multi(int num1, int num2); int karatsu_multi(int num1, int num2);
int multi_repetition(int a, int n);

Loading…
Cancel
Save