Menu
Coddy logo textTech

Least common multiple

Lesson 17 of 32 in Coddy's Coding Problems course.

challenge icon

Challenge

Medium

Write a function named lcm that given two natural numbers a and b from input. Return their LCM in the code block

The Least Common Multiple (LCM) for two integers a and b is the smallest positive integer that is evenly divisible by both a and b.

 

Input
2 3 

Output
6

Input
4 8 

Output 
8

Try it yourself

int lcm(int a1, int a2) {
    // Write code here
}

All lessons in Coding Problems