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.
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
Examples
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.
Programs
-
Mathematica
a[n_] := Block[{m}, Do[m = FromDigits[IntegerDigits[n, b], 10]; If[PrimeQ[m], Return[b]], {b, 2, 10}]; 0]
-
PARI
a(n) = for(b=2, 10, if (isprime(fromdigits(digits(n, b))), return(b))); \\ Michel Marcus, Aug 09 2025
Formula
a(2520*n) = 0.
Comments