cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A343541 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.

This page as a plain text file.
%I A343541 #31 Dec 10 2024 12:28:49
%S A343541 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 A343541 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 A343541 17,17,10,18,18,18,18,13,13,19,19,19
%N A343541 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 A343541 Robert Israel, <a href="/A343541/b343541.txt">Table of n, a(n) for n = 2..10000</a>
%F A343541 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 A343541 f:= proc(n) local p,b,L;
%p A343541     p:= ithprime(n);
%p A343541     for b from floor((1 + sqrt(4*p - 3))/2) by -1 do
%p A343541       L:= convert(p-1,base,b);
%p A343541       if member(b-1,L) then return b fi
%p A343541     od;
%p A343541 end proc:
%p A343541 map(f, [$2 .. 100]); # _Robert Israel_, Dec 10 2024
%t A343541 Table[Max@Select[Range[2,Prime@n-1],MemberQ[IntegerDigits[Prime@n-1,#],#-1]&],{n,2,71}] (* _Giorgos Kalogeropoulos_, Nov 22 2021 *)
%o A343541 (Python)
%o A343541 import sympy
%o A343541 def a_n(N):
%o A343541     a_n=[2]
%o A343541     for i in sympy.primerange(5, N+1):
%o A343541         a_n.append(A338295(i-1))
%o A343541     print(a_n)
%o A343541 def A338295(n):
%o A343541     checker=0
%o A343541     for b in range(n//2, 1,-1):
%o A343541         checker=main_base_check(n, b)
%o A343541         if checker!=0:
%o A343541             break
%o A343541     return checker
%o A343541 def main_base_check(m, b):
%o A343541     while m!=0:
%o A343541         if m%b == b-1:
%o A343541             return b
%o A343541         m = m//b
%o A343541     return 0
%o A343541 a_n(500)
%o A343541 (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 A343541 Cf. A000040, A338295.
%K A343541 nonn,base,look
%O A343541 2,1
%A A343541 _Devansh Singh_, Apr 18 2021