Commits

Shu Zong Chen  committed e227940

added exposition in problem51

  • Participants
  • Parent commits bea9f1f

Comments (0)

Files changed (1)

File problems/problem51.py

 		return v in self.primes
 
 def run():
+	"""
+	Soooo...
+
+	We can narrow down the prime selecting process based on the divisble-by-three
+	principle (that is, that if the sum of the digits of a number is divisible by
+	three then the number is divisible by three).
+
+	That helps because any number that is divisible by three is not prime (that is,
+	any number but three itself).
+
+  The following are charts over the first few n replaced digits.  The chart marks
+	an X where the sum will be a 3.  The last column shows the number of possible
+	primes for this permutation.  Using the charts I will show that you can only
+	ever have an 8 prime family when n is a multiple of three.
+
+	Y axis is sum of other digits mod 10.
+
+  Chart for 1 * replaced digits.
+  =================================
+     Sum of replaced digits
+		 0  1  2  3  4  5  6  7  8  9    Max
+  0  X        X        X        X  | 6
+	1        X        X        X     | 6
+	2     X        X        X        | 6
+	3  X        X        X        X  | 6
+	4  
+	5  ... pattern continues
+	6
+
+  Chart for 2 * replaced digits.
+  =================================
+     Sum of replaced digits
+		0x2 1x2 2x2 3x2 4x2 5x2 6x2 7x2 8x2 9x2
+		 0   2   4   6   8   1   3   5   7   9    Max
+  0  X           X           X           X  | 6
+	1      X           X           X          | 7
+	2          X           X           X      | 7
+	3  X           X           X           X  | 6
+	4  
+	5  ... pattern continues
+	6
+	7
+	8
+	9
+
+  Chart for 3 * replaced digits.
+  =================================
+     Sum of replaced digits
+		0x3 1x3 2x3 3x3 4x3 5x3 6x3 7x3 8x3 9x3
+		 0   3   6   9   3   6   9   3   6   9    Max
+  0  X   X   X   X   X   X   X   X   X   X  | 0
+	1                                         | 9
+	2                                         | 9
+	3  X   X   X   X   X   X   X   X   X   X  | 0
+	4  
+	5  ... pattern continues
+	6
+
+  Chart for 4 * replaced digits.
+  =================================
+     Sum of replaced digits
+		0x4 1x4 2x4 3x4 4x4 5x4 6x4 7x4 8x4 9x4
+		 0   4   8   3   7   2   6   1   5   9    Max
+  0  X           X           X           X  | 6
+	1          X           X           X      | 6
+	2      X           X           X          | 6
+	3  X           X           X           X  | 6
+	4  
+	5  ... pattern continues
+	6
+	7
+
+	"""
 	p = SievedPrimes()
 	p.is_prime(100000)
 	return 0