Computer Science, asked by BrainlyPromoter, 1 year ago

Write a Java program to calculate and print the LCM of two numbers entered by user.

Answers

Answered by Anonymous
4

hey mate

here is the solution...

import java.util.*;

class Lcm

{

public static void main (String args [])

{

Scanner sc=new Scanner (System.in);

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

int a=sc.nextInt();

int b=sc.nextInt();

int lcm=0;

for(int i=1; ;i++)

{

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

{

lcm=i;

break;

}

}

System.out.println("lcm:"+lcm);

}

}

LIKE AS MUCH AS YOU CAN!!!!


Anonymous: just two likes
Anonymous: not fair yaar
Answered by omkaragrawal58265
1

Explanation:

import java.util.*;

class Lcm

{

public static void main (String args [])

{

Scanner sc=new Scanner (System.in);

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

int a=sc.nextInt();

int b=sc.nextInt();

int lcm=0;

for(int i=1; ;i++)

{

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

{

lcm=i;

break;

}

}

System.out.println("lcm:"+lcm);

}

}

HOPE IT WILL HELP YOU

PLEASE MARK ME AS BRAINLIEST AND FOLLOW ME

Similar questions