# HP Forums

Full Version: Strange behaviour of prime numbers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello

I found a strange behaviour in the prime numbers.

About 33.8% of the prime numbers ending by 9 are followed by a prime number ending by 1. On the contrary, only about 15.9% of the prime numbers ending by 3 are followed by a prime number ending by 3 (the same applies with 7 followed by 7 with 15.8%).

The table is as followed :
ending by, followed by, % vs primes endind by
1, 1, 17.1%
1, 3, 31.0%
1, 7, 31.8%
1, 9, 20.1%

3, 1, 23.3%
3, 3, 15.9%
3, 7, 29.1%
3, 9, 31.7%

7, 1, 25.7%
7, 3, 27.4%
7, 7, 15.8%
7, 9, 31.0%

9, 1, 33.8%
9, 3, 25.8%
9, 7, 23.3%
9, 9, 17.1%

Therefore, if you search for a prime number following another one, use this table to maximize your chances.

—- edit —-
Change % to the « primes ending by » instead of to the « total nb of primes ».
(05-20-2019 04:34 PM)fred_76 Wrote: [ -> ]Therefore, if you search for a prime number following another one, use this table to maximize your chances.

First, thanks for sharing. Second, how many primes have you checked?
Is the distribution always valid or is it skewed by primes between a certain range?
(05-20-2019 04:34 PM)fred_76 Wrote: [ -> ]if you search for a prime number following another one, use this table to maximize your chances.

It is funny that I just visited a forum post, Fun with primes and (NewLisp), that may explain your table distribution.

It seems prime gap frequency distribution peak at multiples of 6 (primes upto 1.6 billion)

So, another way to quickly get another prime might be adding multiples of 6, and check primality.
Funny you should mention this. I've started a reading a book called "The Prime Number Conspiracy" Thomas Lin, and IIRC this was the thrust of the title article. I tried a search and came up with this:

Maths experts stunned as they crack a pattern for prime numbers 'I was floored'
Jul 31, 2017

Sorry I can't copy the address on my tablet.

It's a really interesting topic.
(05-23-2019 10:46 PM)tpugsley Wrote: [ -> ]Funny you should mention this. I've started a reading a book called "The Prime Number Conspiracy" Thomas Lin, and IIRC this was the thrust of the title article. I tried a search and came up with this:

Maths experts stunned as they crack a pattern for prime numbers 'I was floored'
Jul 31, 2017

Sorry I can't copy the address on my tablet.

It's a really interesting topic.

.
... and the paper that explains it all is Unexpected biases in the distribution of consecutive primes.

V
.
One has to be careful using empirical counting with prime numbers. The function Li(x) is the integral from 2 to x of dt/ln(t). It has been proven that the difference between Li(x) and Pi(x), which is the prime counting function of all primes less than x, changes sign infinitely many times. However the first sign change isn't known. It's know to happen at a big number.

Lots of other weird things happen.
(05-20-2019 05:34 PM)pier4r Wrote: [ -> ]First, thanks for sharing. Second, how many primes have you checked?
Is the distribution always valid or is it skewed by primes between a certain range?

I checked with the first million of prime numbers. It should be interesting to do the exercise with the next millions to see if these figures are significantly changing.
There's an interesting pattern when the prime numbers are written in base 2. If a prime number ends with the digit 1, the next prime will always end with the same digit. Spooky!
(05-26-2019 07:02 AM)fred_76 Wrote: [ -> ]
(05-20-2019 05:34 PM)pier4r Wrote: [ -> ]First, thanks for sharing. Second, how many primes have you checked?
Is the distribution always valid or is it skewed by primes between a certain range?

I checked with the first million of prime numbers. It should be interesting to do the exercise with the next millions to see if these figures are significantly changing.

Ok but the first million prime numbers are already plenty.

I mean: from the 100'001st and the 200'000 prime number, is the distribution similar to the entire range?

What if between 300k and 400k ? And so on.
Hi, pier4r

Tried it with Mathematica. Distribution looks similar within sub-ranges.

Code:
```keys = {1, 3, 7, 9}; joinlastdigit[x_, y_] := Mod[x, 10]*10 + Mod[y, 10]; keys = Flatten[Table[joinlastdigit[keys[[i]], keys[[j]]], {i, 4}, {j, 4}]]; lastdigitdist[range_] := Block[{n, p, t},    (* distribution percentages *)     n = Length[range];     p = Map[Prime, range];     t = Map[joinlastdigit[p[[#]], p[[#+1]]]&, Range[n-1]];     0.1 * Round[1000 * Map[Count[t, #]&, keys]/n]];```

keys → {11, 13, 17, 19, 31, 33, 37, 39, 71, 73, 77, 79, 91, 93, 97, 99}

lastdigitdist[Range[1, 1000000]] ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ → ﻿{4.3, 7.7, 7.9, 5.0, 5.8, 4.0, 7.3, 7.9, 6.4, 6.9, 4.0, 7.8, 8.5, 6.4, 5.8, 4.3}

lastdigitdist[Range[100001, 200000]] → {4.2, 7.8, 8.1, 4.9, 5.7, 3.8, 7.4, 8.0, 6.4, 7.0, 3.9, 7.8, 8.7, 6.4, 5.7, 4.1}

lastdigitdist[Range[300001, 400000]] → {4.3, 7.7, 8.0, 5.0, 5.8, 4.0, 7.3, 7.9, 6.4, 6.9, 3.9, 7.7, 8.5, 6.4, 5.8, 4.3}

m = 10^6; (* check next million primes *)
lastdigitdist[Range[m+1, m+m]] ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿→ {4.4, 7.6, 7.8, 5.2, 5.9, 4.1, 7.2, 7.8, 6.4, 6.9, 4.1, 7.6, 8.3, 6.4, 5.9, 4.4}
(05-26-2019 10:51 AM)ijabbott Wrote: [ -> ]There's an interesting pattern when the prime numbers are written in base 2. If a prime number ends with the digit 1, the next prime will always end with the same digit. Spooky!

Spooky indeed ;-)

(05-26-2019 05:59 PM)Gerson W. Barbosa Wrote: [ -> ]Spooky indeed ;-)

What’s the fractal dimension of this pattern ?
(05-26-2019 09:10 PM)fred_76 Wrote: [ -> ]
(05-26-2019 05:59 PM)Gerson W. Barbosa Wrote: [ -> ]Spooky indeed ;-)

What’s the fractal dimension of this pattern ?

What makes you think there's a fractal involved here ?

V.
.
(05-26-2019 09:10 PM)fred_76 Wrote: [ -> ]
(05-26-2019 05:59 PM)Gerson W. Barbosa Wrote: [ -> ]Spooky indeed ;-)

What’s the fractal dimension of this pattern ?

Starting from the top, the lines are binary representations of the sequence of prime numbers:

10
11
101
111
...

Just kind of a joke, not spooky at all. Sorry for the confusion.
Here is the graph showing the evolution of the proportions.

Graph 1 is the proportion of primes ending by 1, 3, 7 and 9 to the numbers of primes, by steps of 1 million primes.

[attachment=7323]

The following graphs are showing the proportions of primes ending by 1, 3, 7 and 9 following primes ending by 1, 3, 7 and 9 to the number of primes ending by 1, 3, 7 and 9, again by steps of 1 million primes :

[attachment=7324]

We would expect the curves to be in the range of 25% each, but it is not.

If we write [nm] to identify a couple of primes, the first ending by n followed by the second ending by m then :
- least frequent are the "double ending" 11, 33, 77, 99 with a % of occurence in the range of 17%.
- most frequent is 91 with an occurence of a bit less than 33%
- then 17, 13, 39 and 79 with about 30%
- and 19, 31, 37, 71, 73, 93, 97 between about 21% and 28%

The table for the 10 first million primes is as follows. It shows the proportion of primes ending by n, followed by a prime ending by m, to the number of primes ending by n :

Code:
``` nm    % 11    17.9% 13    30.2% 17    30.8% 19    21.1%      31    23.7% 33    16.9% 37    28.6% 39    30.8%      71    25.6% 73    27.3% 77    16.9% 79    30.3%      91    32.8% 93    25.6% 97    23.7% 99    17.8%```
(05-27-2019 03:41 AM)Gerson W. Barbosa Wrote: [ -> ]Starting from the top, the lines are binary representations of the sequence of prime numbers:

10
11
101
111
...

Nice idea. One could really pick it up and apply it for different things and make sort of pictures out of it.
(05-27-2019 08:38 AM)fred_76 Wrote: [ -> ]Here is the graph showing the evolution of the proportions.
...

Thank you for the research and effort to share these results.

I am frequently amazed and impressed with the enormous amounts of resources and effort folks dedicate to researching Primes, and meta-data about Primes, with no clear predetermined benefit of doing so. Not complaining, just curious why so many people are drawn to research in this area, and what goals they set pursuing such research.

Have any significant non-academic-only results come about as a result of Prime research that isn't well-known, or maybe widely-known, but apparently not by me?
Also, primes ending by 9 followed by a prime ending by 1 then by a prime ending by 7 (917) are about 1.64x more common than the average of the other series of consecutive 3 primes. The figure is about the same for 391.

The least common are the series of primes 111, 333, 777 and 999 which are about 2.3x less common than average.
(05-27-2019 09:27 AM)pier4r Wrote: [ -> ]
(05-27-2019 03:41 AM)Gerson W. Barbosa Wrote: [ -> ]Starting from the top, the lines are binary representations of the sequence of prime numbers:

10
11
101
111
...

Nice idea. One could really pick it up and apply it for different things and make sort of pictures out of it.

Thanks for your interest. In case you have missed it, this old thread might be useful if you to do some experimenting: