Smallest Even Multiple - Problem
Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.
In other words, find the smallest number that is divisible by both 2 and n.
Input & Output
Example 1 — Odd Number
$
Input:
n = 5
›
Output:
10
💡 Note:
Since 5 is odd, the smallest multiple of both 2 and 5 is 2×5 = 10. We can verify: 10÷2 = 5 and 10÷5 = 2.
Example 2 — Even Number
$
Input:
n = 6
›
Output:
6
💡 Note:
Since 6 is even, it's already divisible by 2. The smallest multiple of both 2 and 6 is 6 itself. We can verify: 6÷2 = 3 and 6÷6 = 1.
Example 3 — Small Odd
$
Input:
n = 1
›
Output:
2
💡 Note:
Since 1 is odd, the smallest multiple of both 2 and 1 is 2×1 = 2. We can verify: 2÷2 = 1 and 2÷1 = 2.
Constraints
- 1 ≤ n ≤ 150
Visualization
Tap to expand
Understanding the Visualization
1
Input
Given positive integer n
2
Process
Find LCM of 2 and n
3
Output
Return smallest multiple
Key Takeaway
🎯 Key Insight: The LCM of 2 and n is simply n if n is even, or 2n if n is odd
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code