//Program to find LCM of two(2) numbers.
import java.util.Scanner;
class lcm
{
public static void main(String args[])
{
int a,b,max,lcm=1;
Scanner obj=new Scanner(System.in);
System.out.print("enter 1st number-");
a=obj.nextInt();
System.out.print("enter 2nd no.-");
b=obj.nextInt();
max=(a>b)?a:b;
if(max%a==0 && max%b==0)
lcm=max;
else
lcm=a*b;
System.out.println("lcm of "+a+" and "+b+" is\t"+lcm);
}
}
import java.util.Scanner;
class lcm
{
public static void main(String args[])
{
int a,b,max,lcm=1;
Scanner obj=new Scanner(System.in);
System.out.print("enter 1st number-");
a=obj.nextInt();
System.out.print("enter 2nd no.-");
b=obj.nextInt();
max=(a>b)?a:b;
if(max%a==0 && max%b==0)
lcm=max;
else
lcm=a*b;
System.out.println("lcm of "+a+" and "+b+" is\t"+lcm);
}
}
No comments:
Post a Comment