OFFSET
0,2
COMMENTS
An anagram is a permutation of digits not beginning with 0.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 0..8004 (search of numbers with <= 12 digits; terms 0..511 from Chai Wah Wu)
MATHEMATICA
ap[n_] := Count[FromDigits /@ Select[Permutations[IntegerDigits[n]], First[#] != 0 &], _?PrimeQ]; t = {1}; Do[i = 1; While[ap[i] != n, i++]; AppendTo[t, i], {n, 30}]; t (* Jayanta Basu, Jun 29 2013 *)
PROG
(Python)
from sympy import isprime
from sympy.utilities.iterables import multiset_permutations as mp
from itertools import count, islice, combinations_with_replacement as mc
def nd(d): yield from ("".join((f, )+m) for f in "123456789" for m in mc("0123456789", d-1))
def c(s): return sum(1 for p in mp(s) if p[0]!="0" and isprime(int("".join(p))))
def agen(): # generator of sequence terms
n, adict = 0, dict()
for digs in count(1):
for s in nd(digs):
v = c(s)
if v not in adict: adict[v] = int(s)
while n in adict: yield adict[n]; n += 1
print(list(islice(agen(), 40))) # Michael S. Branicky, Feb 08 2023
CROSSREFS
KEYWORD
nonn,base
AUTHOR
STATUS
approved