-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathlcm.cpp
More file actions
27 lines (27 loc) · 675 Bytes
/
lcm.cpp
File metadata and controls
27 lines (27 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
Author Lakshay Goel
Github profile: https://github.com/MrLakshay
Problem link: https://www.geeksforgeeks.org/program-to-find-lcm-of-two-numbers/
Given are two numbers we need to find their LCM
*/
#include<bits/stdc++.h>
using namespace std;
unsigned long long int gcd(unsigned long long int num1,unsigned long long int num2){
if(num2 == 0){
return num1;
}
else{
gcd(num2,num1%num2);
}
}
unsigned long long int lcm(int a,int b){
unsigned long long int x=gcd(a,b);
unsigned long long int result=((a/x)*(b));
return result;
}
int main()
{
unsigned long long int n1,n2;cin>>n1>>n2;
cout<<lcm(n1,n2);
return 0;
}