Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add fix for problem 2413#172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ashmichheda wants to merge1 commit intofishercoder1534:master
base:master
Choose a base branch
Loading
fromashmichheda:2413-fix
Open
Show file tree
Hide file tree
Changes fromall 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 deletionssrc/main/java/com/fishercoder/solutions/_2413.java
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionssrc/test/java/com/fishercoder/_2413Test.java
View file
Open in desktop
Original file line numberDiff line numberDiff 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);
}
}

[8]ページ先頭

©2009-2025 Movatter.jp