Fw: Last digits of prime numbers

21 views
Skip to first unread message

Richard Donovan

unread,
Apr 17, 2026, 8:44:59 AM (3 days ago) Apr 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 AM (3 days ago) Apr 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 AM (3 days ago) Apr 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 AM (2 days ago) Apr 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 AM (2 days ago) Apr 18
to forum
({., #)/. Is backed by special code. (,#)/.. should use the same, I guess. 

Henry Rich
Reply all
Reply to author
Forward
0 new messages