Once you generate all the n-digit prime permutations, you can use the
histogram verb to find all the primes with the same digits:
p 3
113 131 137 139 173 179 191 193 197 199 311 313 317 331 337 373 379 397 719
733 739 773 797 911 919 937 971 977 991 997
hist=:~.,: #/.~
hist ;10#.ea /:~ ea sep
Here's a verb p(n) to produce all n-digit primes with the same digits:
odo=:#: i.@(*/)
p=:{{(#~1&p:)10#.(odo y#4){1 3 7 9}}
try it:
p 2
11 13 17 19 31 37 71 73 79 97
p 3
113 131 137 139 173 179 191 193 197 199 311 313 317 331 337 373 379 397 719
733 739 773 797 911 919 937 971 977 991 997
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 digit
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