Java program to find HCF and LCM of two numbers

Java program to find HCF and LCM of two numbers. In the java program, find HCF and LCM; it will print the HCF and LCM numbers in the output of the user-entered number.The HCF of given numbers is the largest or greatest factor common to any two or more given natural numbers.When you multiply a number by a whole number, you get a multiple (greater than 0).

import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
int a, b, x, y, t, hcf, lcm;
Scanner scan = new Scanner(System.in);
System.out.print("Enter Two Numbers");
x = scan.nextInt();
y = scan.nextInt();
a = x;
b = y;
while(b != 0)
{
t = b;
b = a%b;
a = t;
}
hcf = a;
lcm = (x*y)/hcf;
System.out.print("HCF = " +hcf);
System.out.print("\nLCM = " +lcm);
}
}

Output:
Enter Two Numbers45                                                                                                           
56                                                                                                                            
HCF = 1                                                                                                                       
LCM = 2520