Computer Science, asked by nike14, 1 year ago

write a program in Java to find LCM of two numbers using while

Answers

Answered by sangeet69
0
package com.devglan; public class LCM { public int findLCM(int a, int b){ int lcm = (a > b) ? a : b; while(true){ if (lcm % a == 0 && lcm % b == 0) { break; } lcm++; } return lcm; } public static void main(String [] args){ LCM lcm = new LCM(); System.out.println("LCM Of "+ 4 +" and " + 6 + " is : " + lcm.findLCM(4,6)); } }
Similar questions