Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/main/java/com/fishercoder/solutions/_2413.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.fishercoder.solutions;

public class _2413 {

public static class Solution1 {
public int smallestEvenMultiple(int n) {
int maxNo = 2 * n;
int smallestMultiple = -1;
for(int i = 2; i <= maxNo; i += 2) {
if (i % n == 0 && i % 2 == 0) {
smallestMultiple = i;
break;
}
}
return smallestMultiple;
}
}
}
25 changes: 25 additions & 0 deletions src/test/java/com/fishercoder/_2413Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.fishercoder;

import com.fishercoder.solutions._2413;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class _2413Test {
private static _2413.Solution1 solution1;
private static int n;

@BeforeClass
public static void setup() {
solution1 = new _2413.Solution1();
}

@Test
public void test1() {
n = 99;
int actual = solution1.smallestEvenMultiple(n);
int expected = 198;
assertEquals(actual, expected);
}
}