/*A Java program to find the HCF and LCM of
two Numbers using Constructor*/
import java.util.Scanner;
import java.lang.*;
class HcfLcm
int n1,n2,t1,t2,t;
HcfLcm(int x,int y)
n1=x;
n2=y;
void Calculate()
t1=n1;
t2=n2;
while(t2!=0)
t=t2;
t2=t1%t2;
t1=t;
}
int hcf=t1;
int lcm = (n1*n2)/hcf;
System.out.println("H.C.F= "+hcf);
System.out.println("L.C.M= "+lcm);
void main()
int x,y;
Scanner sc= new Scanner(System.in);
System.out.print("Enter any two Number:");
x=sc.nextInt();
y=sc.nextInt();
HcfLcm hl = new HcfLcm(x,y);
hl.Calculate();
}
/*A Java program to find the LCM of two Numbers*/
import java.util.Scanner;
class LCM
void main()
int a,b,lcm;
Scanner sc= new Scanner(System.in);
System.out.println("Enter two number:");
a=sc.nextInt();
b=sc.nextInt();
lcm=(a>b)?a:b;
while(true)
if(lcm%a==0 && lcm%b==0)
break;
lcm++;
System.out.println("Lcm of "+a+" and "+b+" ="+lcm);