File tree 2 files changed +43
-0
lines changed
main/java/com/fishercoder/solutions
test/java/com/fishercoder
2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fishercoder .solutions ;
2
+
3
+ public class _2413 {
4
+
5
+ public static class Solution1 {
6
+ public int smallestEvenMultiple (int n ) {
7
+ int maxNo = 2 * n ;
8
+ int smallestMultiple = -1 ;
9
+ for (int i = 2 ; i <= maxNo ; i += 2 ) {
10
+ if (i % n == 0 && i % 2 == 0 ) {
11
+ smallestMultiple = i ;
12
+ break ;
13
+ }
14
+ }
15
+ return smallestMultiple ;
16
+ }
17
+ }
18
+ }
Original file line number Diff line number Diff line change
1
+ package com .fishercoder ;
2
+
3
+ import com .fishercoder .solutions ._2413 ;
4
+ import org .junit .BeforeClass ;
5
+ import org .junit .Test ;
6
+
7
+ import static org .junit .Assert .assertEquals ;
8
+
9
+ public class _2413Test {
10
+ private static _2413 .Solution1 solution1 ;
11
+ private static int n ;
12
+
13
+ @ BeforeClass
14
+ public static void setup () {
15
+ solution1 = new _2413 .Solution1 ();
16
+ }
17
+
18
+ @ Test
19
+ public void test1 () {
20
+ n = 99 ;
21
+ int actual = solution1 .smallestEvenMultiple (n );
22
+ int expected = 198 ;
23
+ assertEquals (actual , expected );
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments