@ -132,6 +132,12 @@ int multiply_using_binary_enumeration(int num1, int num2) {
return result;
}
int multiply_using_differences(int num1, int num2) {
int difference = (num1 > num2) ? num1 - num2 : num2 - num1;
int sum = (num1 > num2) ? num1 + num2 : num2 + num1;
return (sum - difference) * difference / 4;
@ -20,6 +20,7 @@ int multiply_using_increment(int num1, int num2);
int multiply_by_prime_and_its_square(int num, int prime);
int multiply_by_odd(int num, int factor);
int multiply_using_binary_enumeration(int num1, int num2);
int multiply_using_differences(int num1, int num2);
#endif // MULTIPLICATION_H