Created
February 12, 2016 13:28
-
-
Save OrniNoor/bab66219b5a2e2077a10 to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
#include <cstdio> | |
#include <algorithm> | |
#include <cstring> | |
#include <string> | |
#include <cctype> | |
#include <stack> | |
#include <queue> | |
#include <list> | |
#include <vector> | |
#include <map> | |
#include <sstream> | |
#include <cmath> | |
#include <bitset> | |
#include <utility> | |
#include <set> | |
#include <numeric> | |
#include <ctime> | |
#define Infinity 2147483647 | |
#define Pi acos(-1.0) | |
#define N 1000000 | |
#define ll long long | |
#define nodePair pair<int,int> | |
const int dRow [] = {+1,-1,0,0}; | |
const int dCol [] = {0,+1,+1,-1}; | |
#define loop(i, a) for( int i = (0); i < (a); i++ ) | |
#define loopSize(i, sz) for( size_t i = 0; i < sz.size (); i++ ) | |
#define Set(a, s) memset(a, s, sizeof (a)) | |
#define Max(a, b) (a < b ? b : a) | |
#define Min(a, b) (a > b ? b : a) | |
using namespace std; | |
int lcm(int a, int b, int m) | |
{ | |
if(a*m % b == 0) return a*m; | |
return lcm(a, b, m+1); | |
} | |
int gcd(int a, int k) | |
{ | |
if(a%k==0) | |
{ | |
return a; | |
} | |
else | |
{ | |
return gcd(a%k,a); | |
} | |
} | |
int main() | |
{ | |
int num1,num2,res; | |
cin>>num1>>num2; | |
cout<<"GCD: "<<gcd(num1,num2); | |
cout<<"LCM: "<<lcm(num1,num2,1); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment