You won't ever have a pair of 4's in a row. Let's say X is a prime number. We know it's odd as they all are except for 2. Every odd number is going to be either:
A) divisible by 3 (x mod 3 = 0);
B) have a remainder of 1 when divided by 3 (x mod 3 = 1);
C) have a remainder of 2 when divided by 3 (x mod 3 = 2).Let's consider X, X+4 and X + 8 when X is prime:
A) X is divisible by 3 - can't happen when X is prime
B) X mod 3 = 1
Then (X+4) mod 3 = 2
and (X+8) mod 3 = 0.
Therefore X+8 is divisible by 3 and is not prime.
C) X mod 3 = 2
Then (X+4) mod 3 = 0
Therefore X+4 is divisible by 3 and is not prime.So for any prime number X, either X+4 or X+8 will be divisible by 3.
Is that the reason for all the holes in the graph accept the stripes due to even numbers not being prime?
]]> Prime nubers
80 ++-------------------+---------------------+--------------------+---------------------+--------------------+--------------------+---------------------+-------------------++
+ + + + + + + + +
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| M |
| |
| |
| |
| |
| |
| |
| |
| |
60 ++ ++
| |
| M |
| |
| M M |
| |
| |
| |
| M |
| |
| M M M |
| |
| |
| M |
| |
| M M M M M |
| |
| M M |
| |
| |
| |
40 ++ M M M M M ++
| |
| M M M M M M M |
| |
| |
| M |
| |
| M M M M M M M |
| |
| M M M M M M M |
| |
| M M |
| |
| M M M M M M |
| |
| M M M M M M M M M |
| |
| |
| M M M |
| |
| M M M M M M M M M |
| |
20 ++ M M M M M M M M M M ++
| |
| M M M M |
| |
| M M M M M M M M M M M M |
| |
| M M M M M M M M M M M |
| |
| |
| M M M M |
| |
| M M M M M M M M M M M M M M |
| |
| M M M M M M M M M M M M M |
| |
| M M M M M |
| |
| M M M M M M M M M M M M M M |
| |
| M M M M M M M M M M M M M |
| |
0 ++ M M M M M M ++
| |
| |
| M M M M M M M M M M M M |
| |
| M M M M M M M M M M M M M |
| |
| M M M M |
| |
| M M M M M M M M M M M M M M |
| |
| M M M M M M M M M M M |
| |
| M M M |
| |
| |
| M M M M M M M M M M |
| |
| M M M M M M M M M M M M |
| |
| M M M M |
| |
-20 ++ M M M M M M M M M M ++
| |
| M M M M M M M M M M |
| |
| M M M |
| |
| |
| M M M M M M M M M |
| |
| M M M M M M M M |
| |
| M M |
| |
| M M M M M M |
| |
| M M M M |
| |
| M M |
| |
| |
| M M M M M M |
| |
-40 ++ M M ++
| |
| M |
| |
| M M M |
| |
| M M M M M |
| |
| M |
| |
| |
| M M M |
| |
| M |
| |
| M |
| |
| |
| |
| M M M |
| |
-60 ++ ++
| |
| |
| |
| |
| M |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
+ + + + + + + + +
-80 ++-------------------+---------------------+--------------------+---------------------+--------------------+--------------------+---------------------+-------------------++
0 10 20 30 40 50 60 70 80
1st difference
]]>prime, 1st. diff., 2nd. diff., 3rd. diff.
2,1,1,
3,2,0,2
5,2,2,-4
7,4,-2,4
11,2,2,-4
13,4,-2,4
17,2,2,0
19,4,2,-6
23,6,-4,8
29,2,4,-6
.....
So the point for 2 is out of place, because the first difference is 1, unlike for the other primes. I cant figure out how to upload the image.
]]>It looks similar but is more regular in a square way the filled in parts. It makes a wedge and I think there are a few outliers from the wedge shape, but I think they are in the same patterned places as the pattern in the wedge.
Here is what I did. I took the first difference and the second difference and plotted them on each axis.
p_i is the i th prime. P_i+1 is the next prime.
fd_i=p_i+1 - p_i , first difference ,leading
sd_i=fd_i+1 - fd_i , second difference, leading
Plot points, x is fd_i and y is sd_i. This is the forward difference but works for the backward difference too. I played with the third difference in a 3D plot but this was the most interesting patern. There are bands missing and spots missing in a regular pattern.
You will never have a first difference of one.
]]>Example.
Primes 3 5 7 = coordinate 2,2 (5-3,7-5)
I'm still tweeking this, but here is the newer code.
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var primes = [3];
var index = 0;
// takes an odd number and returns true if prime, false if composite
var isPrime = function(num) {
var divisor = num - 1,
testing = true;
while (divisor > 2) {
if (num % divisor === 0) {
return false;
} else {
divisor -= 1;
}
}
return true;
};
// takes an arrawy of primes, looks at the largest, then looks at every other number until it finds a prime and adds it to the primes array
var addPrime = function (primes) {
var topPrime = +primes.slice(-1),
candidate = topPrime + 2,
primeSought = true;
while (primeSought) {
if (isPrime(candidate)) {
primeSought = false;
primes.push(candidate);
} else {
candidate += 2;
}
}
};
var i = 0;
for (i = 0; i < 3; i += 1) {
addPrime(primes);
}
console.log("done");
function draw() {
context.fillStyle = 'rgba(0,0,0,0.3)';
context.fillRect(primes[index+1]-primes[index], primes[index+2]-primes[index+1], 2, 2);
}
function update() {
index += 3;
addPrime(primes);
addPrime(primes);
addPrime(primes);
}
function loop() {
update();
draw();
window.requestAnimationFrame(loop);
}
loop();
HTML:
<body>
<canvas id="myCanvas" width="500" height="500" style="border:1px solid #c3c3c3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
</body>
JS:
var primes = [2,.... lots of primes go here ...., 104723, 104729 ];
var differences = [];
var coordinates = [];
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.fillStyle = "#FF0000";
for (var i = 0; i < primes.length; i++){
differences.push(primes[i] - primes[i-1]);
}
for (var i = 0; i < differences.length; i+=2){
var x = differences[i];
var y = differences[i+1];
coordinates.push([x,y]);
}
for (var i = 0; i < coordinates.length; i++){
var x = coordinates[i][0];
var y = coordinates[i][1];
ctx.fillRect(x,y,2,2);
}
The evolving version will be posted here:
http://codepen.io/Johnesco/pen/OVLVaL?editors=101
I think we can see the pattern, for lack of a better word, want to continue. However, is there anyway to turn this visual pattern into a proof?
]]>Great to hear Ricky!
I'm going to describe it similar to text processing. I'm sure there is a much more efficient way to do it, but this will be easier to describe. My algorithms are less than text-book quality so I'll leave them out. This is a bit of a repeat from above but I'll post it that way for clarity.
1. Create (or read from) a list of prime numbers starting at 3
(3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61...)
2. Make a list of the differences between on number and the next.
3 -> 5 = 2
5 -> 7 = 2 ...(2, 2, 4, 2, 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6 ...)
3. Take the first two numbers in the list (n1 and n2) and plot them as coordinates.
4. Do the same for either a. (n3 and n4) or b. (n2 and n3), I've found both produce interesting results.
That is take...
(2, 2, 4, 2, 4, 2, 4, 6, 2, 6, 4, 2)And plot points
(2,2) (4,2) (4,2) (4,6) (2,6) (4,2)OR. plot to points
(2,2) (2,4) (4,2) (2,4) (4,2) (2,4) (4,6) (6,2) (2,6) (6,4) (4,2)5. Since all numbers are even,optionally divide all numbers by two to collapse the resulting shape of negative empty areas.
Let me know if you have any questions if I have not been clear. I'd post my Python but eek do I have to show the world what a horrible coder I am??? :-)
I made the same.
Only for optimisation: there are many "fast" tests for finding the next prime. I recommend you download some library for computing primes, instead of computing them using Erastritenes' sieve of brute force.
That will save much time for big primes.
I'm going to describe it similar to text processing. I'm sure there is a much more efficient way to do it, but this will be easier to describe. My algorithms are less than text-book quality so I'll leave them out. This is a bit of a repeat from above but I'll post it that way for clarity.
1. Create (or read from) a list of prime numbers starting at 3
(3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61...)
2. Make a list of the differences between on number and the next.
3 -> 5 = 2
5 -> 7 = 2 ...
(2, 2, 4, 2, 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6 ...)
3. Take the first two numbers in the list (n1 and n2) and plot them as coordinates.
4. Do the same for either a. (n3 and n4) or b. (n2 and n3), I've found both produce interesting results.
That is take...
(2, 2, 4, 2, 4, 2, 4, 6, 2, 6, 4, 2)
And plot points
(2,2) (4,2) (4,2) (4,6) (2,6) (4,2)
OR. plot to points
(2,2) (2,4) (4,2) (2,4) (4,2) (2,4) (4,6) (6,2) (2,6) (6,4) (4,2)
5. Since all numbers are even,optionally divide all numbers by two to collapse the resulting shape of negative empty areas.
Let me know if you have any questions if I have not been clear. I'd post my Python but eek do I have to show the world what a horrible coder I am??? :-)
]]>Are there any interested C programmers who could take pseudo code and optimize it?
And I cna use Mathematica for some big primes.
]]>Are there any interested C programmers who could take pseudo code and optimize it?
Yep. I'd be one of those.
]]>