1
1
package com .thealgorithms .maths ;
2
2
3
3
import static org .junit .jupiter .api .Assertions .assertEquals ;
4
- import java . util . List ;
4
+
5
5
import java .util .Arrays ;
6
+ import java .util .List ;
6
7
import org .junit .jupiter .api .Test ;
7
8
8
9
public class ChineseRemainderTheoremTest {
@@ -19,7 +20,7 @@ public void testCRTSimpleCase() {
19
20
public void testCRTLargeModuli () {
20
21
List <Integer > remainders = Arrays .asList (1 , 2 , 3 );
21
22
List <Integer > moduli = Arrays .asList (5 , 7 , 9 );
22
- int expected = 131 ;
23
+ int expected = 156 ;
23
24
int result = ChineseRemainderTheorem .solveCRT (remainders , moduli );
24
25
assertEquals (expected , result );
25
26
}
@@ -37,7 +38,7 @@ public void testCRTWithSingleCongruence() {
37
38
public void testCRTWithMultipleSolutions () {
38
39
List <Integer > remainders = Arrays .asList (0 , 3 );
39
40
List <Integer > moduli = Arrays .asList (4 , 5 );
40
- int expected = 15 ;
41
+ int expected = 8 ;
41
42
int result = ChineseRemainderTheorem .solveCRT (remainders , moduli );
42
43
assertEquals (expected , result );
43
44
}
@@ -46,7 +47,7 @@ public void testCRTWithMultipleSolutions() {
46
47
public void testCRTLargeNumbers () {
47
48
List <Integer > remainders = Arrays .asList (0 , 4 , 6 );
48
49
List <Integer > moduli = Arrays .asList (11 , 13 , 17 );
49
- int expected = 782 ;
50
+ int expected = 550 ;
50
51
int result = ChineseRemainderTheorem .solveCRT (remainders , moduli );
51
52
assertEquals (expected , result );
52
53
}
0 commit comments