Skip to content

Instantly share code, notes, and snippets.

@fpdjsns
Last active September 4, 2017 13:12
Show Gist options
  • Save fpdjsns/d98b5c60afd08971836036308e174c58 to your computer and use it in GitHub Desktop.
Save fpdjsns/d98b5c60afd08971836036308e174c58 to your computer and use it in GitHub Desktop.
#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