Calculating LCM is based on calculating GCD:
Get LCM by Euclid algorithm :
int LCM_Euclid(int &n,int &m) { if(n==0||m==0) return 0; int a=n,b=m,k; while(a%b!=0) { a%=b; swap(a,b); } return n*m/b; }
Calculating LCM is based on calculating GCD:
Get LCM by Euclid algorithm :
int LCM_Euclid(int &n,int &m) { if(n==0||m==0) return 0; int a=n,b=m,k; while(a%b!=0) { a%=b; swap(a,b); } return n*m/b; }