Computer Science, asked by deepmaan, 1 year ago

write the program in Java to accept two numbers and find the LCM of the two numbers using buffer reader

Answers

Answered by siddhartharao77
4
public static void main(String args[])
{
BufferedReader demo= new BufferedReader(new InputStreamReader(System.in));

int x,y,z = 1;
System.out.println("Enter 1st number");
x = Integer.parseInt(br.readline());
System.out.println("Enter 2nd number");
y = Integer.parseInt(br.readline());

for(int i = x; i<= x * y; i++)
{
if(i%x == 0 && i%y == 0)
{
z = i;
break;
}
}
System.out.println("Therefore the LCM is :" +z);
}
}


Hope this helps!
Similar questions