login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

For n > 1, a(n) is the largest base b <= prime(n)-1 such that the digits of prime(n)-1 in base b contain the digit b-1.
1

%I #31 Dec 10 2024 12:28:49

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

%T 12,5,3,13,13,13,5,6,6,14,14,10,10,15,15,5,5,11,11,16,16,2,3,4,5,17,

%U 17,17,10,18,18,18,18,13,13,19,19,19

%N For n > 1, a(n) is the largest base b <= prime(n)-1 such that the digits of prime(n)-1 in base b contain the digit b-1.

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

%F a(n) <= (1 + sqrt(4*prime(n) - 3))/2 for all n. Prime(n), which is 111 in some base Q, has a(n) = Q+1. Example: 31 = 6*5 + 1 and it is 111 in base 5. - _Devansh Singh_, Nov 22 2021

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

%p p:= ithprime(n);

%p for b from floor((1 + sqrt(4*p - 3))/2) by -1 do

%p L:= convert(p-1,base,b);

%p if member(b-1,L) then return b fi

%p od;

%p end proc:

%p map(f, [$2 .. 100]); # _Robert Israel_, Dec 10 2024

%t Table[Max@Select[Range[2,Prime@n-1],MemberQ[IntegerDigits[Prime@n-1,#],#-1]&],{n,2,71}] (* _Giorgos Kalogeropoulos_, Nov 22 2021 *)

%o (Python)

%o import sympy

%o def a_n(N):

%o a_n=[2]

%o for i in sympy.primerange(5, N+1):

%o a_n.append(A338295(i-1))

%o print(a_n)

%o def A338295(n):

%o checker=0

%o for b in range(n//2, 1,-1):

%o checker=main_base_check(n, b)

%o if checker!=0:

%o break

%o return checker

%o def main_base_check(m, b):

%o while m!=0:

%o if m%b == b-1:

%o return b

%o m = m//b

%o return 0

%o a_n(500)

%o (PARI) a(n) = my(q=prime(n)-1); forstep(b=q, 2, -1, if (vecmax(digits(q, b)) == b-1, return (b))); \\ _Michel Marcus_, Apr 19 2021

%Y Cf. A000040, A338295.

%K nonn,base,look

%O 2,1

%A _Devansh Singh_, Apr 18 2021