OFFSET
1,7
EXAMPLE
n=19: 2^19 = 524288, has 180 permutations, each composite, a(19)=0;
n=13: 2^13 = 8192, the following 5 of the 24 permutations provide primes: {8219, 8291, 1289, 9281, 2819}.
MATHEMATICA
Table[Count[FromDigits/@Permutations[IntegerDigits[2^n]], _?PrimeQ], {n, 50}] (* Harvey P. Dale, Mar 04 2026 *)
PROG
(PARI) \\ here b(n) is A039999.
b(n)={my(D=vecsort(digits(n)), S=0); forperm(D, p, if(isprime(fromdigits(Vec(p))), S++)); S}
{ for(n=1, 30, print1(b(2^n), ", ")) } \\ Andrew Howroyd, Jan 05 2020
(Python)
from sympy import isprime
from sympy.utilities.iterables import multiset_permutations as mp
def a(n): return sum(1 for p in mp(str(2**n)) if isprime(int("".join(p))))
print([a(n) for n in range(1, 31)]) # Michael S. Branicky, May 25 2023
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Labos Elemer, Aug 04 2003
EXTENSIONS
a(27)-a(44) from Andrew Howroyd, Jan 05 2020
a(45)-a(49) from Michael S. Branicky, May 26 2023
Previous Mathematica program replaced by Harvey P. Dale, Mar 04 2026
STATUS
approved
