Computer Science, asked by AyanChattopadhyay, 1 year ago

38. Write a program to input two integers, and find their Least Common Multiple(L.C.M).
For Example,
INPUT:
Enter 2 integers:
12
OUTPUT:
L.C.M. = 24

write this program in JavaScript (bluej)​

Answers

Answered by Anonymous
6

Explanation:

import java.util.*;

class Lcm

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in());

int a,b;

System.out.println("enter two numbers");

a=sc.nextInt();

b=sc.nextInt();

for(int i=1;i<=a*b:i++)

{

if(i%a==0 && i%b==0)

{

System.out.print("lcm is"+i);

break;

}

}

}

}

Similar questions