Skip to content

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.

Easy#2413
LeetCode Problem

Smallest Even Multiple

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

Input
n = 5
Output
10

# Example 2

Input
n = 6
Output
6

Constraints

1 <= n <= 150

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.