login

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

For 1 < k <= n, let m be the largest number such that k^1, k^2, ... k^m are palindromes in base n. a(n) gives the smallest k which has the largest value of m.
1

%I #27 Jun 22 2015 00:16:24

%S 2,2,2,2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,5,2,3,2,2,2,2,2,2,2,2,6,

%T 2,2,2,2,2,2,2,2,2,2,2,2,7,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,

%U 2,2,2,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,10,2,2,2,2,2,2,2,6,2,2,2,2,2,2,2,2,2,2,2,2,11,2,2,2,5,2,2,2,2,2,2

%N For 1 < k <= n, let m be the largest number such that k^1, k^2, ... k^m are palindromes in base n. a(n) gives the smallest k which has the largest value of m.

%C Excluding repetitions, this is a permutation of the natural numbers excluding all perfect powers (i.e., this sequence contains N if and only if N is in A007916). - _Derek Orr_, Jun 18 2015

%H Christian Perfect, <a href="/A258757/b258757.txt">Table of n, a(n) for n = 2..1000</a>

%e a(8) = 3 because the first 6 powers of 3 are palindromes in base 8, which is more than any other number in the range 2..8 (here, m = 6).

%o (Python)

%o def to_base(n,b):

%o ...s = []

%o ...while n:

%o ......m = n%b

%o ......s = [m]+s

%o ......n = (n-m)//b

%o ...return s

%o .

%o def is_palindrome(n):

%o ...return n==n[::-1]

%o .

%o def num_palindromes(n,b):

%o ...if n<2:

%o ......return 0

%o ...t = 1

%o ...while is_palindrome(to_base(n**t,b)):

%o ......t+=1

%o ...return t-1

%o .

%o def most_palindromes(b):

%o ...return max(range(2,b+1),key=lambda n:num_palindromes(n,b))

%o (PARI) a(n)=v=[-1];for(k=2,n,i=1;c=0;while(i,d=digits(k^i,n);if(Vecrev(d)==d,c++);if(Vecrev(d)!=d,break);i++);if(c>v[#v],v=concat(v,c);m=k));m

%o vector(100,n,a(n+1)) \\ _Derek Orr_, Jun 18 2015

%Y Cf. A007916.

%K nonn,base

%O 2,1

%A _Christian Perfect_, Jun 09 2015