Practice Smallest Even Multiple
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Return the smallest positive integer divisible by both n and 2, where n is positive. The result must be a multiple of n as well as even. Practice approach: If n is already even, n itself works. If n is odd, its next multiple, 2 * n, is the first even one. This is the least common multiple of n and 2 without a general-purpose GCD calculation. Time and extra space are O(1). Test n = 1, an even value, and an odd value.
Source: Smallest Even Multiple on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 5
10
# Example 2
n = 6
6
Constraints
Related LeetCode Problems
Practice more problems similar to Smallest Even Multiple.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.