Skip to content

Commit 62fcbb8

Browse files
committed
chore: Adjust result to be the smallest positive solution in ChineseRemainderTheorem
1 parent 92c6211 commit 62fcbb8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/test/java/com/thealgorithms/maths/ChineseRemainderTheoremTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package com.thealgorithms.maths;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4-
import java.util.List;
4+
55
import java.util.Arrays;
6+
import java.util.List;
67
import org.junit.jupiter.api.Test;
78

89
public class ChineseRemainderTheoremTest {
@@ -19,7 +20,7 @@ public void testCRTSimpleCase() {
1920
public void testCRTLargeModuli() {
2021
List<Integer> remainders = Arrays.asList(1, 2, 3);
2122
List<Integer> moduli = Arrays.asList(5, 7, 9);
22-
int expected = 131;
23+
int expected = 156;
2324
int result = ChineseRemainderTheorem.solveCRT(remainders, moduli);
2425
assertEquals(expected, result);
2526
}
@@ -37,7 +38,7 @@ public void testCRTWithSingleCongruence() {
3738
public void testCRTWithMultipleSolutions() {
3839
List<Integer> remainders = Arrays.asList(0, 3);
3940
List<Integer> moduli = Arrays.asList(4, 5);
40-
int expected = 15;
41+
int expected = 8;
4142
int result = ChineseRemainderTheorem.solveCRT(remainders, moduli);
4243
assertEquals(expected, result);
4344
}
@@ -46,7 +47,7 @@ public void testCRTWithMultipleSolutions() {
4647
public void testCRTLargeNumbers() {
4748
List<Integer> remainders = Arrays.asList(0, 4, 6);
4849
List<Integer> moduli = Arrays.asList(11, 13, 17);
49-
int expected = 782;
50+
int expected = 550;
5051
int result = ChineseRemainderTheorem.solveCRT(remainders, moduli);
5152
assertEquals(expected, result);
5253
}

0 commit comments

Comments
 (0)