A demonstration machine has two meshed gears. The first gear is fixed: it completes exactly one full rotation every 2 seconds, no matter what. The second gear is swapped out between demonstrations and completes one full rotation every n seconds, where n is a positive integer chosen for that demonstration. The technician wants to know the very first moment, in whole seconds after the machine starts, at which both gears simultaneously finish a whole number of rotations at once — that is, the elapsed time must be a common multiple of 2 and of n. Given n, find that smallest positive number of seconds.
A single line containing one integer n.
Print a single integer: the smallest positive integer that is a multiple of both 2 and n.
Example 1
Input
6
Expected
6
Explanation
n=6 is already even, so it is itself a multiple of 2 as well as of 6. The smallest common multiple of 2 and 6 is therefore 6.
Example 2
Input
5
Expected
10
Explanation
n=5 is odd, so it is not a multiple of 2. The smallest number that is a multiple of both 2 and 5 is 2*5=10.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →