import java.util.*;
class ranjan
{
public static void main(String args[])
{
int a,b,c,d,temp,hcf,lcm;
Scanner sc=new Scanner(System.in);
System.out.print("Enter two numbers : ");
a=sc.nextInt();
b=sc.nextInt();
c=a;
d=b;
while(d!=0)
{
temp=d;
d=c%d;
c=temp;
}
hcf=c;
lcm=(a*b)/hcf;
System.out.println("HCF = "+hcf);
System.out.println("LCM = "+lcm);
}
}
Output:
Enter two numbers : 6 9HCF = 3
LCM = 18
0 Comments