login
Smallest base relative to which n is palindromic.
8

%I #47 Jan 17 2024 14:30:09

%S 2,3,2,3,2,5,2,3,2,3,10,5,3,6,2,3,2,5,18,3,2,10,3,5,4,3,2,3,4,9,2,7,2,

%T 4,6,5,6,4,12,3,5,4,6,10,2,4,46,7,6,7,2,3,52,8,4,3,5,28,4,9,6,5,2,7,2,

%U 10,5,3,22,9,7,5,2,6,14,18,10,5,78,3,8,3,5,11,2,6,28,5,8,14,3,6

%N Smallest base relative to which n is palindromic.

%C From _Hieronymus Fischer_, Jan 05 2014: (Start)

%C The terms are well defined since each number m > 2 is palindromic in base m - 1.

%C A number n > 6 is prime, if a(n) = n - 1.

%C Numbers m of the form m = q * p with q < p - 1, are palindromic in base p - 1, and therefore a(m) <= p.

%C Numbers m of the form m := j*(p^k - 1)/(p - 1), 1 <= j < p are palindromic in base p, and therefore: a(m) <= p.(End)

%H Hieronymus Fischer, <a href="/A016026/b016026.txt">Table of n, a(n) for n = 1..10000</a> (first 1000 from Vincenzo Librandi).

%H K. S. Brown, <a href="http://www.mathpages.com/home/kmath359.htm">On General Palindromic Numbers</a>

%F From _Hieronymus Fischer_, Jan 05 2014: (Start)

%F a(A016038(n)) = A016038(n) - 1, for n > 3.

%F a(A006995(n)) = 2, for n > 1.

%F a(A002113(n)) <= 10 for n > 1. (End)

%F To put Fischer's comments in words: if n > 3 is a strictly non-palindromic number (A016038), then a(n) = n - 1. If n > 1 is a binary palindrome (A006995), then a(n) = 2. And if n > 1 is a decimal palindrome, then a(n) <= 10. - _Alonso del Arte_, Sep 15 2017

%e n = 4 = 11_3 is palindromic in base 3, but not palindromic in base 2, hence a(4) = 3. [Typo corrected by _Phil Ronan_, May 22 2014]

%e n = 14 = 22_6 is palindromic in base 6, but not palindromic in any other base < 6, hence a(14) = 6.

%t palQ[n_, b_] := Reverse[x = IntegerDigits[n, b]] == x; Table[base = 2; While[!palQ[n, base], base++]; base, {n, 92}] (* _Jayanta Basu_, Jul 26 2013 *)

%o (PARI) ispal(n, b) = my(d=digits(n,b)); d == Vecrev(d);

%o a(n) = my(b=2); while (! ispal(n, b), b++); b; \\ _Michel Marcus_, Sep 22 2017

%o (Python)

%o from itertools import count

%o from sympy.ntheory.factor_ import digits

%o def A016026(n): return next(b for b in count(2) if (s := digits(n,b)[1:])[:(t:=len(s)+1>>1)]==s[:-t-1:-1]) # _Chai Wah Wu_, Jan 17 2024

%Y Cf. A016038, A006995, A002113.

%K nonn,base

%O 1,1

%A _Robert G. Wilson v_