15int gcd(
int num1,
int num2) {
16 if (num1 <= 0 | num2 <= 0) {
17 throw std::domain_error(
"Euclidean algorithm domain is for ints > 0");
25 int previous_remainder = 1;
29 previous_remainder = num2;
32 previous_remainder = num1;
35 while ((base_num % previous_remainder) != 0) {
36 int old_base = base_num;
37 base_num = previous_remainder;
38 previous_remainder = old_base % previous_remainder;
41 return previous_remainder;