#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b;
int e=a, f=b;
while(b!=0)
{
int t=b;
b=a%b;
a=t;
}
c=(e*f)/a;
cout<<c<<endl;
return 0;
}
with function:
//Bismillah-hir-rah-ma-nir-rahim(in the name of Allah)
//Thinker: Arafat Kamal Tamzid(Sylhet Engineering College)
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
int t,e,f;
e=a,f=b;
while(b!=0)
{
t=b;
b=a%b;
a=t;
}
int lcd=(e*f)/a;
return lcd;
}
int main()
{
int a,b,c;
cin>>a>>b;
c=gcd(a,b);
cout<<c<<endl;
return 0;
}
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b;
int e=a, f=b;
while(b!=0)
{
int t=b;
b=a%b;
a=t;
}
c=(e*f)/a;
cout<<c<<endl;
return 0;
}
with function:
//Bismillah-hir-rah-ma-nir-rahim(in the name of Allah)
//Thinker: Arafat Kamal Tamzid(Sylhet Engineering College)
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
int t,e,f;
e=a,f=b;
while(b!=0)
{
t=b;
b=a%b;
a=t;
}
int lcd=(e*f)/a;
return lcd;
}
int main()
{
int a,b,c;
cin>>a>>b;
c=gcd(a,b);
cout<<c<<endl;
return 0;
}
No comments:
Post a Comment