Browse Source

multiplication by odd

remotes/origin/multiplication
fdai7930 11 months ago
parent
commit
5bf1c9753e
  1. 9
      src/multiplication.c
  2. 1
      src/multiplication.h

9
src/multiplication.c

@ -112,5 +112,14 @@ int multiply_by_prime_and_its_square(int num, int prime) {
return num * (prime + square (prime)); return num * (prime + square (prime));
} }
int multiply_by_odd(int num, int factor) {
int result = 0;
for (int i = 0; i < factor; ++i) {
result += num;
}
return result;
}

1
src/multiplication.h

@ -18,6 +18,7 @@ int multiply_using_modulo(int num1, int num2, int modulo);
int multiply_by_prime(int num, int prime); int multiply_by_prime(int num, int prime);
int multiply_using_increment(int num1, int num2); int multiply_using_increment(int num1, int num2);
int multiply_by_prime_and_its_square(int num, int prime); int multiply_by_prime_and_its_square(int num, int prime);
int multiply_by_odd(int num, int factor);
#endif // MULTIPLICATION_H #endif // MULTIPLICATION_H

Loading…
Cancel
Save