Update appNew update is available. Click here to update.
sidenav-btnClose
Topic list
Ninja And The LCM
EASY
15 mins
13 upvotes
Other topics
Problem solved
Badge
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
Linked List
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
userLevel
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

Ninja And The LCM

Contributed by
kamalsharmaa9
Easy
yellow-spark
0/40
Avg time to solve 15 mins
Success Rate 86 %
Share
13 upvotes

Problem Statement

Ninja has given two numbers ‘X’ and ‘Y’. He has to find the LCM of these two numbers.

LCM (Least Common Multiple) of two numbers is the smallest number that can be divisible by both numbers.

As you are his big brother. So help Ninja in calculating the LCM.

EXAMPLE:
Input: 'X' = 2,  ‘Y’=3

Output: "6"

As “6” is the smallest number that is divisible by both 2 and 3.
Detailed explanation ( Input/output format, Notes, Constraints, Images )
Sample Input 1 :
2
2 7
6 8
Sample Output 1 :
14
24
Explanation Of Sample Input 1 :
In test case ‘1’, before 8 to 13, all numbers are not divided by both ‘2’ and ‘7’ both. So ‘14’ is the smallest number divisible by both ‘2’ and ‘7’. So LCM of ‘2’ and ‘7’ is ‘14’.
In test case ‘2’, ‘24’ is the smallest number divisible by both ‘6’ and ‘8’ so the answer is ‘24’.
Sample Input 2 :
2
8 8
6 24
Sample Output 2 :
8
24
Reset Code
Full screen
Auto
copy-code
Console