Skip to content

2413. Smallest Even Multiple 👍

  • Time: $O(1)$
  • Space: $O(1)$
1
2
3
4
5
6
class Solution {
 public:
  int smallestEvenMultiple(int n) {
    return n * (n % 2 + 1);
  }
};
1
2
3
4
5
class Solution {
  public int smallestEvenMultiple(int n) {
    return n * (n % 2 + 1);
  }
}
1
2
3
class Solution:
  def smallestEvenMultiple(self, n: int) -> int:
    return n * (n % 2 + 1)