write a program to find the LCM & GCD of two numbers
LuckyYadav2578:
in which language?
Answers
Answered by
4
import java.util.Scanner; public class JavaProgram { 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 Number : "); 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); } }
Similar questions
Chemistry,
7 months ago
Physics,
7 months ago
English,
1 year ago
Social Sciences,
1 year ago
Physics,
1 year ago
Biology,
1 year ago
Computer Science,
1 year ago