HCF LCM of 2no

 Write a program to input two numbers and display their HCF and LCM.

 

import java.util.Scanner; class HCFLCMof2No { public static void main() { int x, y; System.out.println("Enter two integers to calculate their HCF and LCM"); Scanner in = new Scanner(System.in); x = in.nextInt(); y = in.nextInt(); int lcm=1; while(lcm % x !=0 || lcm % y !=0) lcm ++; System.out.println("LCM of integers "+x+" and "+y +" is "+lcm); System.out.println("HCF of integers "+x+" and "+y +" is "+(x*y)/lcm); } }



For any desired program, please comment below. We will try our best to make that program available.

Comments

Popular Posts