Skip to content

Commit

Permalink
SolutionByGurirath.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurirath authored Oct 7, 2023
1 parent c7b27cd commit e6122a8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Basic/Find LCM of Two Numbers/SolutionByGurirath.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

/**
Write a program to print the lcm of two numbers.
*/
import java.util.*;
public class hacktoberfest4
{
public static void main(String args[])
{
Scanner kb= new Scanner(System.in);
int i,n1,n2;
System.out.println("Enter two numbers to check their lcm");
n1=kb.nextInt();
n2=kb.nextInt();
for(i=2;i<Math.max(n1,n2);i++)
{
if(n1%i==0 && n2%i==0)
{
System.out.println("The LCM is : "+i);
break;
}
}
}
}

0 comments on commit e6122a8

Please sign in to comment.