Back to all solutions

#2413 - Smallest Even Multiple

Problem Description

Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.

Solution

/**
 * @param {number} n
 * @return {number}
 */
var smallestEvenMultiple = function(n) {
  return n * (n % 2 + 1);
};