login
A386929
a(n) is the least base b in {2,...,10} such that the base-b expansion of n, when read as a decimal integer, is prime; a(n) = 0 if no such base exists.
2
0, 3, 2, 3, 2, 5, 4, 5, 6, 3, 4, 9, 4, 0, 6, 5, 4, 0, 4, 0, 5, 3, 2, 0, 6, 5, 6, 5, 4, 0, 7, 0, 5, 3, 8, 0, 4, 7, 6, 0, 5, 0, 4, 0, 6, 3, 2, 9, 8, 7, 0, 7, 4, 0, 4, 5, 8, 3, 7, 0, 4, 0, 5, 9, 8, 9, 3, 5, 0, 0, 4, 0, 4, 0, 8, 0, 4, 0, 3, 0, 5, 9, 4, 9, 7, 0, 6, 9, 2, 0, 4, 0, 6, 3, 8
OFFSET
1,2
COMMENTS
There are infinitely many zeros since if n is a multiple of 2520, then each base-b expansion ends with digit 0.
LINKS
FORMULA
a(2520*n) = 0.
a(630*n) = 0. - Robert Israel, Sep 09 2025
EXAMPLE
a(10) = 3 since 10 in base 3 is "101" and 101 is prime; base 2 is "1010" -> 1010 composite.
a(11) = 4 since base 4 gives "23" -> 23 is prime; base 2 "1011" -> 1011 composite; base 3 "102" -> 102 composite.
a(23) = 2 since base 2 gives "10111" -> 10111 is prime.
MAPLE
f:= proc(n) local b, L, i;
for b from 2 to 10 do
L:= convert(n, base, b);
if isprime(add(L[i]*10^(i-1), i=1..nops(L))) then return b fi
od;
0
end proc:
map(f, [$1..100]); # Robert Israel, Sep 09 2025
MATHEMATICA
a[n_] := Block[{m}, Do[m = FromDigits[IntegerDigits[n, b], 10]; If[PrimeQ[m], Return[b]], {b, 2, 10}]; 0]
PROG
(PARI) a(n) = for(b=2, 10, if (isprime(fromdigits(digits(n, b))), return(b))); \\ Michel Marcus, Aug 09 2025
CROSSREFS
Cf. A036952 (the twos), A038537, A052026 (the zeros), A052033 (the tens).
Sequence in context: A258778 A112924 A267148 * A388299 A367682 A230406
KEYWORD
nonn,base
STATUS
approved