Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 534 Bytes

2413.最小偶倍数.md

File metadata and controls

32 lines (26 loc) · 534 Bytes

2413.最小偶倍数

/*
 * @lc app=leetcode.cn id=2413 lang=typescript
 *
 * [2413] 最小偶倍数
 */

// @lc code=start
function smallestEvenMultiple(n: number): number {}
// @lc code=end

解法 1: 模拟

function smallestEvenMultiple(n: number): number {
  return n % 2 === 0 ? n : 2 * n
}

Case

test.each([
  { input: { n: 5 }, output: 10 },
  { input: { n: 6 }, output: 6 },
])('input: n = $input.n', ({ input: { n }, output }) => {
  expect(smallestEvenMultiple(n)).toEqual(output)
})