L.C.M and H.C.F Program

www.programmingcalculator.com
https://nikhilnihal.github.io/programmingcalculator/index.html

C++  PROGRAM  FOR  FINDING  H.C.F.  &  L.C.M.



#include<bits/stdc++.h>
 
int main() 
{
  int a, b, x, y, t, gcd, lcm;
 
  cin>>a>>b;
 
  a = x;
  b = y;
 
  while (b != 0) {
    t = b;
    b = a % b;
    a = t;
  }
 
  gcd = a;
  lcm = (x*y)/gcd;
 
  cout<<gcd<<endl;
  cout<<hcf<<endl;
 
  return 0;
}

Comments

Popular posts from this blog

Getting Started With MEAN App Development with AngularJs , ExpressJs , NodeJs and MongoDB.

B. Dreamoon and WiFi :calculate no. of ways : recursive solution (branch and bound )

A. Dreamoon and Stairs : minimum steps to reach : recursion solution.