Skip to content

Commit 4d975ec

Browse files
committed
feat: solve No.2413
1 parent b0e2c30 commit 4d975ec

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

Diff for: 2401-2500/2413. Smallest Even Multiple.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# 2413. Smallest Even Multiple
2+
3+
- Difficulty: Easy.
4+
- Related Topics: Math, Number Theory.
5+
- Similar Questions: Greatest Common Divisor of Strings, Three Divisors, Find Greatest Common Divisor of Array, Convert the Temperature, Minimum Cuts to Divide a Circle.
6+
7+
## Problem
8+
9+
Given a **positive** integer ```n```, return **the smallest positive integer that is a multiple of **both** **```2```** and **```n```.
10+
 
11+
Example 1:
12+
13+
```
14+
Input: n = 5
15+
Output: 10
16+
Explanation: The smallest multiple of both 5 and 2 is 10.
17+
```
18+
19+
Example 2:
20+
21+
```
22+
Input: n = 6
23+
Output: 6
24+
Explanation: The smallest multiple of both 6 and 2 is 6. Note that a number is a multiple of itself.
25+
```
26+
27+
 
28+
**Constraints:**
29+
30+
31+
32+
- ```1 <= n <= 150```
33+
34+
35+
36+
## Solution
37+
38+
```javascript
39+
/**
40+
* @param {number} n
41+
* @return {number}
42+
*/
43+
var smallestEvenMultiple = function(n) {
44+
return n % 2 === 0 ? n : n * 2;
45+
};
46+
```
47+
48+
**Explain:**
49+
50+
nope.
51+
52+
**Complexity:**
53+
54+
* Time complexity : O(n).
55+
* Space complexity : O(n).

0 commit comments

Comments
 (0)