OFFSET
2,1
LINKS
Robert Israel, Table of n, a(n) for n = 2..10000
FORMULA
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
MAPLE
f:= proc(n) local p, b, L;
p:= ithprime(n);
for b from floor((1 + sqrt(4*p - 3))/2) by -1 do
L:= convert(p-1, base, b);
if member(b-1, L) then return b fi
od;
end proc:
map(f, [$2 .. 100]); # Robert Israel, Dec 10 2024
MATHEMATICA
Table[Max@Select[Range[2, Prime@n-1], MemberQ[IntegerDigits[Prime@n-1, #], #-1]&], {n, 2, 71}] (* Giorgos Kalogeropoulos, Nov 22 2021 *)
PROG
(Python)
import sympy
def a_n(N):
a_n=[2]
for i in sympy.primerange(5, N+1):
a_n.append(A338295(i-1))
print(a_n)
def A338295(n):
checker=0
for b in range(n//2, 1, -1):
checker=main_base_check(n, b)
if checker!=0:
break
return checker
def main_base_check(m, b):
while m!=0:
if m%b == b-1:
return b
m = m//b
return 0
a_n(500)
(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
CROSSREFS
KEYWORD
AUTHOR
Devansh Singh, Apr 18 2021
STATUS
approved