-
-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} |