A384211 a(n) is the number of distinct ways of representing n in any integer base >= 2 using only prime digits.
0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 2, 1, 2, 2, 2, 1, 4, 2, 3, 2, 3, 1, 6, 2, 3, 4, 4, 1, 6, 2, 5, 4, 5, 2, 7, 2, 7, 4, 5, 3, 8, 4, 9, 3, 7, 3, 12, 3, 6, 5, 6, 4, 11, 2, 9, 4, 9, 6, 13, 3, 11, 8, 12, 3, 12, 3, 13, 7, 8, 5, 14, 5, 13, 5, 11, 4, 15, 3, 13, 8, 10, 7, 15
Offset: 0
Examples
The a(43) = 9 representations of [4,3] in base 10 using only prime digits are [2,2,3] in base 4, [5,3] in base 8, [3,7] in base 12, [2,13] in base 15, [2,11] in base 16, [2,7] in base 18, [2,5] in base 19, [2,3] in base 20 and [43] in bases >= 44.
Links
- Felix Huber, Table of n, a(n) for n = 0..10000
Programs
-
Maple
A384211:=proc(n) local a,b,c; a:=0; for b from 2 to n+1 do c:=convert(n,'base',b); if select(isprime,c)=c then a:=a+1 fi od; return a end proc; seq(A384211(n),n=0..87); A384211representations:=proc(n) local L,b,c; L:=[]; for b from 2 to n+1 do c:=convert(n,'base',b); if select(isprime,c)=c then L:=[op(L),b,ListTools:-Reverse(c)] fi od; return op(L) end proc; A384211representations(43);
-
Mathematica
a[n_] := Boole[PrimeQ[n]] + Count[Range[2, n-1], ?(AllTrue[IntegerDigits[n, #], PrimeQ] &)]; Array[a, 100 ,0] (* _Amiram Eldar, May 23 2025 *)
-
PARI
a(n) = sum(k=2, n+1, my(d=digits(n, k)); #select(isprime, d) == #d); \\ Michel Marcus, May 26 2025
-
Python
from sympy import isprime from sympy.ntheory import digits def a(n): return len(set(t for b in range(2, n+2) if all(map(isprime, (t:=tuple(digits(n, b)[1:])))))) print([a(n) for n in range(84)]) # Michael S. Branicky, May 23 2025
Comments