Skip to main content
Back to problems
#2413
Easy Algorithms

Smallest even multiple

Math Number Theory
88.3% acceptance
Feb 25, 2026
1049
126
Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.

Solution

Rust
Time O(1)
Space O(1)
LeetCode
solution.rs
impl Solution {
  pub fn smallest_even_multiple(n: i32) -> i32 {
    if n % 2 == 0 { n } else { 2 * n }
  }
}