# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a258757 Showing 1-1 of 1 %I A258757 #27 Jun 22 2015 00:16:24 %S A258757 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 A258757 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 A258757 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 A258757 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 A258757 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 A258757 Christian Perfect, Table of n, a(n) for n = 2..1000 %e A258757 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 A258757 (Python) %o A258757 def to_base(n,b): %o A258757 ...s = [] %o A258757 ...while n: %o A258757 ......m = n%b %o A258757 ......s = [m]+s %o A258757 ......n = (n-m)//b %o A258757 ...return s %o A258757 . %o A258757 def is_palindrome(n): %o A258757 ...return n==n[::-1] %o A258757 . %o A258757 def num_palindromes(n,b): %o A258757 ...if n<2: %o A258757 ......return 0 %o A258757 ...t = 1 %o A258757 ...while is_palindrome(to_base(n**t,b)): %o A258757 ......t+=1 %o A258757 ...return t-1 %o A258757 . %o A258757 def most_palindromes(b): %o A258757 ...return max(range(2,b+1),key=lambda n:num_palindromes(n,b)) %o A258757 (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 A258757 vector(100,n,a(n+1)) \\ _Derek Orr_, Jun 18 2015 %Y A258757 Cf. A007916. %K A258757 nonn,base %O A258757 2,1 %A A258757 _Christian Perfect_, Jun 09 2015 # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE