@@ -50,29 +50,33 @@ public void testSetOfQuadraticResidues() {
50
50
51
51
/**
52
52
* Test the number of quadratic residues modulo 2^n for n = 0, 1, 2, ...
53
- * This gives number sequences
54
- * A023105(n) = 1, 2, 2, 3, 4, 7, 12, 23, 44, 87, 172, 343, ... for general quadratic residues modulo 2^n, and
55
- * a(n) = {1, 1} + A023105(n-2) = 1, 1, 1, 2, 2, 3, 4, 7, 12, 23, 44, 87, 172, 343, 684, 1367, 2732, 5463, 10924, 21847, ... for "even" quadratic residues modulo 2^n.
56
- */
53
+ * This gives number sequence A023105(n) = 1, 2, 2, 3, 4, 7, 12, 23, 44, 87, 172, 343, ... */
57
54
@ Test
58
55
public void testQuadraticResiduesMod2PowNCounts () {
59
56
ArrayList <Integer > counts = new ArrayList <Integer >();
60
- ArrayList <Integer > evenCounts = new ArrayList <Integer >();
61
-
62
57
for (int n =0 ; n <20 ; n ++) {
63
58
int m = 1 <<n ;
64
-
65
59
TreeSet <Long > quadraticResiduesMod2PowN = QuadraticResidues .getQuadraticResidues (m );
66
60
if (DEBUG ) LOG .debug ("m = " + m + " has " + quadraticResiduesMod2PowN .size () + " quadratic residues: " + quadraticResiduesMod2PowN );
67
61
counts .add (quadraticResiduesMod2PowN .size ());
62
+ }
63
+ LOG .info ("counts = " + counts );
64
+ assertEquals ("[1, 2, 2, 3, 4, 7, 12, 23, 44, 87, 172, 343, 684, 1367, 2732, 5463, 10924, 21847, 43692, 87383]" , counts .toString ());
65
+ }
68
66
67
+ /**
68
+ * Test the number of even quadratic residues modulo 2^n for n = 0, 1, 2, ...
69
+ * This gives number sequence a(n) = {1, 1} + A023105(n-2) = 1, 1, 1, 2, 2, 3, 4, 7, 12, 23, 44, 87, 172, 343, 684, 1367, 2732, 5463, 10924, 21847, ...
70
+ */
71
+ @ Test
72
+ public void testEvenQuadraticResiduesMod2PowNCounts () {
73
+ ArrayList <Integer > evenCounts = new ArrayList <Integer >();
74
+ for (int n =0 ; n <20 ; n ++) {
75
+ int m = 1 <<n ;
69
76
TreeSet <Long > evenQuadraticResiduesMod2PowN = QuadraticResidues .getEvenQuadraticResidues (m );
70
77
if (DEBUG ) LOG .debug ("m = " + m + " has " + evenQuadraticResiduesMod2PowN .size () + " 'even' quadratic residues: " + evenQuadraticResiduesMod2PowN );
71
78
evenCounts .add (evenQuadraticResiduesMod2PowN .size ());
72
79
}
73
-
74
- LOG .info ("counts = " + counts );
75
- assertEquals ("[1, 2, 2, 3, 4, 7, 12, 23, 44, 87, 172, 343, 684, 1367, 2732, 5463, 10924, 21847, 43692, 87383]" , counts .toString ());
76
80
LOG .info ("evenCounts = " + evenCounts );
77
81
assertEquals ("[1, 1, 1, 2, 2, 3, 4, 7, 12, 23, 44, 87, 172, 343, 684, 1367, 2732, 5463, 10924, 21847]" , evenCounts .toString ());
78
82
}
0 commit comments