login
a(n) is the least base, other than 10, in which the decimal digits of n represent a prime, or 0 if there is no such base.
1

%I #11 Jan 28 2021 18:43:38

%S 3,4,0,6,0,8,0,0,0,2,3,4,7,6,7,12,9,14,0,3,0,4,0,6,0,8,0,11,0,4,5,0,5,

%T 6,0,8,11,0,0,7,0,5,0,6,0,9,0,11,0,6,7,8,11,0,7,8,9,14,0,7,0,0,0,7,0,

%U 9,0,0,0,16,11,8,9,8,11,0,9,14,0,9,0,13,0,12,0,9,0,11,0,12,11,0,11

%N a(n) is the least base, other than 10, in which the decimal digits of n represent a prime, or 0 if there is no such base.

%H Robert Israel, <a href="/A337164/b337164.txt">Table of n, a(n) for n = 2..10000</a>

%e a(12) = 3 because 12_3 = 5 is prime.

%p f:= proc(n) local L,b,i,x,v,p;

%p L:= convert(n,base,10);

%p if L[1] = 0 or igcd(op(L)) > 1 or not irreduc(add(L[i]*x^(i-1),i=1..nops(L))) then return 0 fi;

%p b:= max(L)+1;

%p if b = 10 then b:= 11 fi;

%p v:= add(L[i]*b^(i-1),i=1..nops(L));

%p if isprime(v) then return b fi;

%p for p in numtheory:-factorset(v) do

%p if andmap(t -> add(L[i]*t^(i-1),i=1..nops(L)) mod p = 0, [$0..p-1]) then return 0 fi;

%p od;

%p for b from b+1 to 10^4 do

%p if b = 10 then next fi;

%p if isprime(add(L[i]*b^(i-1),i=1..nops(L))) then return b fi

%p od;

%p FAIL

%p end proc:

%p f(2):= 3: f(3):= 4: f(5):= 6: f(7):= 8:

%p map(f, [$2..200]);

%K nonn,base

%O 2,1

%A _J. M. Bergot_ and _Robert Israel_, Jan 28 2021