Browse Source

multiplication using increment

remotes/origin/multiplication
fdai7930 11 months ago
parent
commit
78f549c633
  1. 7
      src/multiplication.c
  2. 1
      src/multiplication.h

7
src/multiplication.c

@ -100,6 +100,13 @@ int multiply_by_prime(int num, int prime) {
return num * (prime - 1) + num; return num * (prime - 1) + num;
} }
int multiply_using_increment(int num1, int num2) {
int result = 0;
for (int i = 0; i < num2; ++i) {
result += num1;
}
return result;
}

1
src/multiplication.h

@ -16,6 +16,7 @@ int multiply_using_lookup_table(int num1, int num2);
int multiply_using_logical_operations(int num1, int num2); int multiply_using_logical_operations(int num1, int num2);
int multiply_using_modulo(int num1, int num2, int modulo); 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);
#endif // MULTIPLICATION_H #endif // MULTIPLICATION_H

Loading…
Cancel
Save