FunctionRacerProblemsRace

Kth Multiple of Either

HardMathPython, JavaScript, TypeScript, Java, C++

List the positive whole numbers that are divisible by a or by b (or both), from small to large. Return the k-th one, counting from 1.

Example 1

k 4
a 2
b 3
returns 6

The list starts 2, 3, 4, 6, 8, 9, ... and its fourth number is 6.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems