Fw: Last digits of prime numbers

60 views
Skip to first unread message

Richard Donovan

unread,
Apr 17, 2026, 8:44:59 AMApr 17
to forum


Sent from Outlook for iOS

From: Richard Donovan <rsdo...@hotmail.com>
Sent: Friday, April 17, 2026 11:27:09 AM
To: J Programming <progr...@jsoftware.com>
Subject: Last digits of prime numbers
 
Hi

There has been a recent Numberfile video re new investigations into
the sequence of the last digits of prime numbers. It has  been know for
Some time that the possible candidates (1, 3, 7, 9) are not present in
Equable amounts, and there has recently been a new discovery which
Supposes that certain of the prime endings have a bias to what the next
Ending might be.

In order to follow this discovery I have written the following J program that
Runs through a given number of primes and tabulates the amount of prime
Endings. This is the first step before I consider biases in following primes.

This is the program I am using:

1#.'1379'=/>{.each |.each ":each p:i.1000000
249934 250110 250014 249940

It seems to produce the correct results but I am sure there must be a
Better (and no doubt faster) way to do this calculation.

I'm sure I don't need three 'eachs' but can't find a way round it.

Grateful for any help,

Thanks in advance,

Richard

chris burke

unread,
Apr 17, 2026, 10:02:18 AMApr 17
to fo...@jsoftware.com
(#,{.) /.~ 2 5 -.~ 10 | p: i.1000000
250110 3
250014 7
249934 1
249940 9

Richard Donovan

unread,
Apr 17, 2026, 11:15:07 AMApr 17
to fo...@jsoftware.com
Thanks!

Sent from Outlook for iOS

From: chris burke <cbu...@jsoftware.com>
Sent: Friday, April 17, 2026 3:01:37 PM
To: fo...@jsoftware.com <fo...@jsoftware.com>
Subject: Re: [Jforum] Fw: Last digits of prime numbers
 
To unsubscribe from this group and stop receiving emails from it, send an email to forum+un...@jsoftware.com.

Jan-Pieter Jacobs

unread,
Apr 18, 2026, 4:28:47 AMApr 18
to fo...@jsoftware.com
I was about to suggest using (,#)/..~ rather than ({.,#)/.~ but was surprised to see it's far slower and fatter, while I thought this was exactly the use-case for which /.. was introduced...

100 timespacex '({.,#)/.~ 2 5-.~ 10 | pr'

0.0046416 8.39088e6

100 timespacex '(,#)/..~ 2 5-.~ 10 | pr'

0.0113772 1.67963e7


Jan-Pieter



Henry Rich

unread,
Apr 18, 2026, 5:28:31 AMApr 18
to forum
({., #)/. Is backed by special code. (,#)/.. should use the same, I guess. 

Henry Rich

Remington Furman

unread,
Apr 21, 2026, 6:49:04 PMApr 21
to fo...@jsoftware.com

It has been know for Some time that the possible candidates (1, 3, 7, 9) are not present in
Equable amounts,

Not true in base 2, where every prime after 2 ends in 1.  ;)

   (] /: {."1)&.>  <@(({.,#)/.~)"(1) (2+i.15) |"(0 1) p: i.1000000
+--------+--------+--------+--------+--------+--------+--------+--------+--------+---------+---------+--------+---------+---------+---------+
|0      1|0      1|1 499798|0      1|1 499829|0      1|1 249796|1 166568|1 249934| 0      1| 1 249739| 0     1| 1 166671| 1 124840| 1 124858|
|1 999999|1 499829|2      1|1 249934|2      1|1 166671|2      1|2 166751|2      1| 1  99925| 2      1| 1 83314| 2      1| 2 124960| 2      1|
|        |2 500170|3 500201|2 250015|3      1|2 166651|3 250091|3      1|3 250110| 2 100000| 3      1| 2 83341| 3 166708| 3      1| 3 125116|
|        |        |        |3 250110|5 500169|3 166708|5 250002|4 166637|5      1| 3 100051| 5 250059| 3 83355| 5 166683| 4 124890| 5 124931|
|        |        |        |4 249940|        |4 166636|7 250110|5 166707|7 250014| 4  99994| 7 250090| 4 83267| 7      1| 5      1| 7 125001|
|        |        |        |        |        |5 166683|        |7 166624|9 249940| 5 100007|11 250110| 5 83396| 9 166650| 7 125055| 9 124938|
|        |        |        |        |        |6 166650|        |8 166712|        | 6 100082|         | 6 83369|11 166636| 8 125065|11 124975|
|        |        |        |        |        |        |        |        |        | 7  99983|         | 7 83367|13 166650|11 125094|13 125071|
|        |        |        |        |        |        |        |        |        | 8  99905|         | 8 83339|         |13 125044|15 125109|
|        |        |        |        |        |        |        |        |        | 9 100024|         | 9 83309|         |14 125050|         |
|        |        |        |        |        |        |        |        |        |10 100028|         |10 83213|         |         |         |
|        |        |        |        |        |        |        |        |        |         |         |11 83412|         |         |         |
|        |        |        |        |        |        |        |        |        |         |         |12 83317|         |         |         |
+--------+--------+--------+--------+--------+--------+--------+--------+--------+---------+---------+--------+---------+---------+---------+

-Remington

Richard Donovan

unread,
Apr 30, 2026, 5:32:29 AMApr 30
to forum, Remington Furman
It has also been suggest that some digits are more likely
follow other digits than seems random.

EG 1 follow 9 more that 7 follows 3 (as consecutive last
digits than would be expected.

I am trying to make a matrix that shows the percentage of y that
follows x such as

          d1         d3          d7         d9    
d1    %d1d1 %d1d3 %d1d7 %d1d9
d3    %d3d1
d7
d9

where %d1d3 is %age of times 3 follows 1 as last digit of prime etc

If I ever get this working I guess it would be interesting to investigate
the third number in the series etc!

Richard
Reply all
Reply to author
Forward
0 new messages