index | submit | rank | book

lcm – Least Common Multiple (LCM)

Write a program that computes the least common multiple (LCM) of two integers.

Here are a few examples:

Venn diagram for the LCM between 12 and 18

Input and Output

Input will contain multiple lines each with two integers m and n in the range:

0 < m, n < 1 000 000

For each line of input your program should produce a line of output with the LCM of m and n.

Input is given so that the resulting LCM should be less than 1 000 000 000.

Example input

12 18
100 60
8 10

Example output


The lcm function

Your program should be implemented using a lcm function that receives two integers as arguments and returns an integer. Please refer to the information for the chosen language:


Submit your solution to be graded according to the following list:


Can you reuse your code from the gcd exercise?

try first: gcd

try next: primes roundiv

index | submit | rank | book

Copyright © 2020-2023 Rudy Matela
All rights reserved