A million is not that big--brute force works out just fine:
a=. >:i.1e6
k=. (10 <.@:^. a) ,. /:~"1]10 #.inv a
k ;@:(<@({:#~[:*./1&p:)@]/..) a
2 3 5 7 11 31 71 73 97 311 991 733
On Sat, 23 Sep 2023, Richard Donovan wrote:
Hi
I am trying to develop a program to find primes with n digits abc such that acb
bac bca cab and cba are also primes. (obviously trivial if aaa is prime!).
An example with n=3 is
1 p: 199 919 991
1 1 1
These primes are thin on the ground since they cannot contain any of the digits
2 4 5 6 8 or 0 and I am wondering if it would be best to construct numbers
omitting those containing those prohibited digits, or test every comination of
p: i. n which seems wasteful, especially since I want to find all such primes
below one million.
Can anyone see an efficent way to produce this?
Thanks in advance,
Richard
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm