Last active
September 4, 2017 13:12
-
-
Save fpdjsns/d98b5c60afd08971836036308e174c58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int gcd(int a, int b) | |
{ | |
if (b == 0) return a; | |
else | |
return gcd(b, a%b); | |
} | |
int lcm(int a, int b) | |
{ | |
int tmp = gcd(a, b); | |
return a*b / tmp; | |
} | |
int main() | |
{ | |
int a, b; | |
int temp; | |
cin >> a >> b; | |
cout << "최대공약수 : " << gcd(a, b) << endl; | |
cout << "최소공배수 : " << lcm(a, b) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment