Close
Topic list
Ninja And The LCM
EASY
15 mins
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
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
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
0/40
Avg time to solve 15 mins
Success Rate 86 %
Share

## Problem Statement

#### 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
``````
Auto
Console