@@ -14,30 +14,30 @@ public class ExponentiationTest {
14
14
15
15
@ Test
16
16
public void recusriveExponentiationTest () {
17
- List <Integer > baseList = Arrays .asList (1 , 2 , 4 , 6 , 8 , 17 , 24 );
18
- List <Integer > exponentList = Arrays .asList (1000 , 27 , 14 , 11 , 10 , 7 , 5 );
19
- List <Integer > expectedResultList = Arrays .asList (1 , 134217728 , 268435456 , 362797056 , 1073741824 , 410338673 , 7962624 );
17
+ final List <Integer > baseList = Arrays .asList (1 , 2 , 4 , 6 , 8 , 17 , 24 );
18
+ final List <Integer > exponentList = Arrays .asList (1000 , 27 , 14 , 11 , 10 , 7 , 5 );
19
+ final List <Integer > expectedResultList = Arrays .asList (1 , 134217728 , 268435456 , 362797056 , 1073741824 , 410338673 , 7962624 );
20
20
21
21
for (int i = 0 ; i < expectedResultList .size (); i ++)
22
22
assertEquals (expectedResultList .get (i ), Exponentiation .recursiveExponentiation (baseList .get (i ), exponentList .get (i )));
23
23
}
24
24
25
25
@ Test
26
26
public void fastRecusriveExponentiationTest () {
27
- List <Integer > baseList = Arrays .asList (1 , 2 , 4 , 6 , 8 , 17 , 24 );
28
- List <Integer > exponentList = Arrays .asList (1000 , 27 , 14 , 11 , 10 , 7 , 5 );
29
- List <Integer > expectedResultList = Arrays .asList (1 , 134217728 , 268435456 , 362797056 , 1073741824 , 410338673 , 7962624 );
27
+ final List <Integer > baseList = Arrays .asList (1 , 2 , 4 , 6 , 8 , 17 , 24 );
28
+ final List <Integer > exponentList = Arrays .asList (1000 , 27 , 14 , 11 , 10 , 7 , 5 );
29
+ final List <Integer > expectedResultList = Arrays .asList (1 , 134217728 , 268435456 , 362797056 , 1073741824 , 410338673 , 7962624 );
30
30
31
31
for (int i = 0 ; i < expectedResultList .size (); i ++)
32
32
assertEquals (expectedResultList .get (i ), Exponentiation .fastRecursiveExponentiation (baseList .get (i ), exponentList .get (i )));
33
33
}
34
34
35
35
@ Test
36
36
public void fastRecusriveExponentiationModuloTest () {
37
- List <Integer > baseList = Arrays .asList (1 , 2 , 4 , 6 , 8 , 17 , 24 );
38
- List <Integer > exponentList = Arrays .asList (1000 , 27 , 14 , 11 , 10 , 7 , 5 );
39
- List <Integer > divisorList = Arrays .asList (2 , 6 , 3 , 2 , 9 , 11 , 5 );
40
- List <Integer > expectedResultList = Arrays .asList (1 , 2 , 1 , 0 , 1 , 8 , 4 );
37
+ final List <Integer > baseList = Arrays .asList (1 , 2 , 4 , 6 , 8 , 17 , 24 , 2 );
38
+ final List <Integer > exponentList = Arrays .asList (1000 , 27 , 14 , 11 , 10 , 7 , 5 , 1089 );
39
+ final List <Integer > divisorList = Arrays .asList (2 , 6 , 3 , 2 , 9 , 11 , 5 , 2179 );
40
+ final List <Integer > expectedResultList = Arrays .asList (1 , 2 , 1 , 0 , 1 , 8 , 4 , 2178 );
41
41
42
42
for (int i = 0 ; i < expectedResultList .size (); i ++)
43
43
assertEquals (expectedResultList .get (i ), Exponentiation .fastRecursiveExponentiationModulo (baseList .get (i ), exponentList .get (i ), divisorList .get (i )));
0 commit comments