I am very new to C++ and am attempting create a function to implement the Euclidean algorithm that returns the greatest common divisor for two integer inputs.
The current approach I am taking keeps crashing - can you help me understand why?
int main() {
int a = 0;
int b = 0;
cin >> a;
cin >> b;
do {
if ( a > b ) a = a % b;
else if ( a < b ) b = b % a;
else if ( a == b ) break;
} while ( ( a || b ) != 0 );
return 0;
}
Thanks,
David