Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**BluemanSteele****Member**- Registered: 2006-12-31
- Posts: 8

Hi everyone. This is my first post so I hope this is the right place.

I started a project in 1993 with prime numbers and recently picked it back up.

The first time I did this I worked in QBasic. Now I'm doing it in Python.

I'm only a hobbyist in programing and math, so I'd like to see if someone

with more knowledge than me in both can let me know if I've found something

new or if I'm just seeing a side effect of known properties of primes.

Here are the steps to my findings.

1. Take 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. Note the pair of 2s and 6s, but no pair of 4s

I noticed this in 1993 but the numbers I was working in had to stay in the tens of thousands and thus my hunch had no "proof".

I tried various ways of graphing this and found a pattern of "holes" missing from the gaps between primes.

I was told this was just a side effect of sieve of eratosthenes, but the pattern is so regular and predictable that I wanted to find out more about it.

I'm not a mathematician nor a programmer, just a very curious person. So I'd love to find out more, but worry I might not understand the answer. If anyone is patient and curious, I'd love to share my findings and see what can be discovered.

Thanks in advance.

Offline

**pi man****Member**- Registered: 2006-07-06
- Posts: 251

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.

Offline

**BluemanSteele****Member**- Registered: 2006-12-31
- Posts: 8

Thanks Pi man. The rest of the pattern (of non-pairs) is 4,16,28,...(intervals of 12) and 8,20,32,... (also intervals of 12).

These all seem to follow what you've described.

I'm running this into the millions for the first time with python and glad to know what they show.

I'll post some pictures when I can.

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,663

Excellent first post, Blueman, and welcome to the forum.

Primes are so fascinating, and useful too.

"The physicists defer only to mathematicians, and the mathematicians defer only to God ..." - Leon M. Lederman

Offline

**mathsyperson****Moderator**- Registered: 2005-06-22
- Posts: 4,900

Indeed they are. I think pi man's proof can be applied to any even number that isn't a multiple of 3, so as well as the numbers you've mentioned, you also won't find any pairs of 10, 22, 34... (in intervals of 12) or 14, 26, 38... (in intervals of 12).

You also won't find any pairs of 2 apart from the pair that start off the sequence. pi man's proof still works there, and the pair of 2's exists because they describe the differences between 3, 5, 7. pi man's proof says that one of those is a multiple of 3, which 3 is, but it is also prime.

Incidentally, whenever you see a 2 in that sequence of differences, it means that you've found a pair of twin primes (two consecutive odd numbers that are both prime). No one knows whether the twin primes go on for infinity or not. There's probably a vastly huge sum of money being offered somewhere for anyone who can prove either way whether they do.

Anyway, a very warm welcome to the forum. Have lots of fun here.

*Last edited by mathsyperson (2007-01-01 06:28:00)*

Why did the vector cross the road?

It wanted to be normal.

Offline

**Toast****Real Member**- Registered: 2006-10-08
- Posts: 1,321

Why yes, quite an interesting proof pi man

Offline

**mathsyperson****Moderator**- Registered: 2005-06-22
- Posts: 4,900

...Ooops. It's a shame this forum doesn't have an embarassment smilie.

Why did the vector cross the road?

It wanted to be normal.

Offline

**krassi_holmz****Real Member**- Registered: 2005-12-02
- Posts: 1,905

Hi Blueman. I like your first post too.

IPBLE: Increasing Performance By Lowering Expectations.

Offline

**pi man****Member**- Registered: 2006-07-06
- Posts: 251

I've always been fascinated with primes. There's got to be some sort of pattern in there somewhere. Many, many, years ago I tried using different bases (binary, hex, etc.) to see if any patterns jumped out. Then the use of the internet began to growth quickly and I discovered that primes were fascinating to many. Brilliant minds have spent countless hours on this and I realized that finding a pattern is not going to be as simple as me converting the numbers to a different power-based system.

I still think that a completely different numbering system might be the answer. For example, instead of a power-based system, how about a prime-based system? So instead of expressing a number in ones, tens and hundreds..., express them in terms of 2's, 3's, 5's, 7's, etc.

Decimal PrimeBased

0 0

1 1

2 10

3 100

4 20

5 1000

6 110

7 10000

8 30

9 200

10 1010

11 100000

12 120

Basically this numbering system is expressing the prime factorization in a numeric form. From right to left, the columns are the prime numbers: 1, 2, 3, 5, 7, 11. So 6 in this system (3^1) * (2^1) * (1^0). 12 is (3^1) * (2^2) * (1^0). This system has not helped much and it has its flaws. Although the columns are prime-based, the actual digits are decimal. So 4 is represented as 20 but "2" in this system is 10. So 4 should really be 10\0 with a "" separating the digits. Make any sense?

I would like to write more but our New Year's guests have arrived. Happy New Year's to all you mathematicians!

*Last edited by pi man (2007-01-01 17:11:57)*

Offline

**krassi_holmz****Real Member**- Registered: 2005-12-02
- Posts: 1,905

Happy new year (january, 2, 18:20)!

The prime are really disorsered. As pi man said "Brilliant minds have spent countless hours on this ..." I either don't think some pattern ever exists.

I may be wrong, but changing the base may help in some cases, but it's a special case of the number theory with congurents. I think the prime numbers should have some fractal properties, in some system, not the usual, but based on another mathematical rule. For example, there's a theorem (which I rediscovered before knowing it's been already discovered), saying that every integer can be represented in an unique way as a sum of non-succesive numbers of Fibonacci. I think this, because of some requrrent definitions and properties of the prime numbers, such as the Erastrotenes sieve.

And another - I don't think that many of the results will be computer-generated. For a theorem to be proved, it isn't sufficient to be true for numbers up to a million, nor up to 10^million. You need a proof.

Nowadays, there are some very interesting results about prime numbers, involving contemporary mathematics, such as integrals, fields, modular functions. Every "spheres" of maths are connected. I like the analytical number theory, but i don't understand not a bit of it.

And there are some general unsolved hypotesis, which, when proved, will have general consequenses to all fields in mathematics.

Some of the most popular are the Riemann's hypothesis and ABC conjecture.

I think we haven't mathematically "grown" enough to understand all the proprties of the prime numbers. But I think that some day we will. And I hope to be soon.

IPBLE: Increasing Performance By Lowering Expectations.

Offline

**BluemanSteele****Member**- Registered: 2006-12-31
- Posts: 8

Regarding prime pairs. There is a way to plot this info in 2D that makes that prime pairs visible.

Take the list of differences (2, 2, 4, 2, 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6 ...)

and plot them (n1,n2) (n3, n4)

basically take each pair and turn them into coordinates.

This will show that not only do prime pairs (primes 2 aparts) continue to happen over and over, but so do many other combinations (minus certain holes). These holes in the scatter graph that forms are very constant as the graph fills.

You can also start "late" in the sequence and find it fills in both directions.

It's as if to say "all distances between primes exists at all sizes" minus of course the holes I originally posted about.

I have images, is there a way I could post them?

In a scary form of ascii art, here is the pattern as it seems to fall, all odd spaces are removed so this grid represents even numbers only with the origin in the lower left.

```
ooooooooooooooooooooo
o oo oo oo oo oo oo o
oo oo oo oo oo oo oo
ooooooooooooooooooooo
o oo oo oo oo oo oo o
oo oo oo oo oo oo oo
ooooooooooooooooooooo
o oo oo oo oo oo oo o
oo oo oo oo oo oo oo
ooooooooooooooooooooo
o oo oo oo oo oo oo o
oo oo oo oo oo oo oo
ooooooooooooooooooooo
o oo oo oo oo oo oo o
oo oo oo oo oo oo oo
```

The actual scatter graph looks more like this....

```
oo
o o
oo o
oooo
o oo
oo oo o (very random placement)
ooooooo
o oo oo o
oo oo oo o
oooooooooooo o
o oo oo oo oo
oo oo oo oo oo
oooooooooooooooooo
o oo oo oo oo oo
oo oo oo oo oo oo oo
^
Here at origin, pattern gets very solid very quickly.
```

Aha! Posted image as my avatar!

*Last edited by BluemanSteele (2007-01-02 23:23:03)*

Offline

**krassi_holmz****Real Member**- Registered: 2005-12-02
- Posts: 1,905

Intersting.

There's a conjecture, that for every even n, there exists infinitely many prime couples (p,q), such that p-q=n.

Intersting pattern.

Does your avatar has some connection with this?

I like it very much.

You can upload images, using "upload image", when you're posting and using the

`[img]`

tag.

Something like:

`[url]http://the_place_where_your_image_is[/url]`

You can also read the forum features.

*Last edited by krassi_holmz (2007-01-03 04:33:58)*

IPBLE: Increasing Performance By Lowering Expectations.

Offline

**BluemanSteele****Member**- Registered: 2006-12-31
- Posts: 8

Ok I've figured out how to post images, I'll edit this post and put up a more interesting one.

While this post is up, the picture below is much like my avatar but color and height coded to show repeated "hits" on that spot.

Higher and brighter = more repetition.

*Last edited by BluemanSteele (2007-01-03 05:03:01)*

Offline

**BluemanSteele****Member**- Registered: 2006-12-31
- Posts: 8

krassi_holmz wrote:

Intersting.

There's a conjecture, that for every even n, there exists infinitely many prime couples (p,q), such that p-q=n.

Intersting pattern.

Does your avatar has some connection with this?

My avatar and the now posted image show prime couples everywhere that one of the coordinates is 2.

Since the origin is at the bottom left, the left and bottom most sides of the image represent (2,x) and (x,2) of the coordinate system.

This pattern has always grown in this way and would really love to see it pushed into the billions if possible (my avatar shows about 80,000 primes or the primes from 3 to 1 million). I know it's not a 'proof' but it's an interesting map to show new pairs of all sorts consistently growing.

Are there any interested C programmers who could take pseudo code and optimize it?

*Last edited by BluemanSteele (2007-01-03 09:44:37)*

Offline

**Ricky****Moderator**- Registered: 2005-12-04
- Posts: 3,791

Are there any interested C programmers who could take pseudo code and optimize it?

Yep. I'd be one of those.

"In the real world, this would be a problem. But in mathematics, we can just define a place where this problem doesn't exist. So we'll go ahead and do that now..."

Offline

**krassi_holmz****Real Member**- Registered: 2005-12-02
- Posts: 1,905

Are there any interested C programmers who could take pseudo code and optimize it?

And I cna use Mathematica for some big primes.

IPBLE: Increasing Performance By Lowering Expectations.

Offline

**BluemanSteele****Member**- Registered: 2006-12-31
- Posts: 8

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??? :-)

Offline

**krassi_holmz****Real Member**- Registered: 2005-12-02
- Posts: 1,905

Here are two plots, made them with mathematica.

The first is for all numbers to the 100000th prime number (not 100000)!

The second - to 1000000th prime number:

*Last edited by krassi_holmz (2007-01-03 12:51:04)*

IPBLE: Increasing Performance By Lowering Expectations.

Offline

**krassi_holmz****Real Member**- Registered: 2005-12-02
- Posts: 1,905

BluemanSteele wrote:

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.

IPBLE: Increasing Performance By Lowering Expectations.

Offline

**BluemanSteele****Member**- Registered: 2006-12-31
- Posts: 8

Thanks! Those look great.

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?

Offline

**krassi_holmz****Real Member**- Registered: 2005-12-02
- Posts: 1,905

I don't know.

But here's some results:

There's a theorem, stating that for every number k, there exists infinity couples of consecutive prime numbers, such that the gap between them is greater or equal to k. Graphically that means, that when we have enough prime numbers, this graphic will cover some square, no matter what the square side is. More basically, this structure *grows*.

Not so helpful, but it's proven to be true.

IPBLE: Increasing Performance By Lowering Expectations.

Offline

**BluemanSteele****Member**- Registered: 2006-12-31
- Posts: 8

But can it be proven to grow infinitely? :-)

Offline

**JohnEsco****Member**- Registered: 2015-04-16
- Posts: 2

So here I am posting 8 years later just to show how tech has changed and how much processing power we have in just the browser with Javascript now.

This was whipped up in minutes and will go through many versions and improvements.

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

Offline

**JohnEsco****Member**- Registered: 2015-04-16
- Posts: 2

I think I've managed to clean up the code considerably. Also instead of processing the primes ahead of time, I'm making the primes I need and constructing the differences 3 prime numbers at a time.

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();
```

Offline

**Luca Ravioli****Member**- Registered: 2017-06-29
- Posts: 5

I got a pattern also using the second difference!!!! I searched to find your pattern.

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.

Offline