Smallest Even Multiple

Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.

30:00

Smallest Even Multiple
easy
Free written solution
Topics
Companies

Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.

Example 1:
Input: {"n":5}
Output: 10
Constraints:
  • 1≤n≤1501 \leq n \leq 150

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"n":5}

Find the smallest positive number divisible by both 2 and 5, that is lcm(2, 5).

hops of n = 5
ticks = multiples of 2
0510

n % 2 = ?

lcm(2, n) = 2 · n / gcd(2, n) = 2 · 5 / 1

Variables
VariableValue
n5
DepthFunction Call
Stack empty
0/4