(
intnum1,
intnum2) {
15 if(num1 <= 0 | num2 <= 0) {
16 throwstd::domain_error(
"Euclidean algorithm domain is for ints > 0");
35 return gcd(num1 - num2, num2);
36 return gcd(num1, num2 - num1);
43std::cout <<
"gcd of 120,7 is "<< (
gcd(120, 7)) << std::endl;
45std::cout <<
"gcd of -120,10 is "<<
gcd(-120, 10) << std::endl;
46}
catch(
conststd::domain_error &e) {
47std::cout <<
"Error handling was successful"<< std::endl;
49std::cout <<
"gcd of 312,221 is "<< (
gcd(312, 221)) << std::endl;
50std::cout <<
"gcd of 289,204 is "<< (
gcd(289, 204)) << std::endl;
int gcd(int num1, int num2)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4