|
|
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.
|
|
1
|
|
|
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, 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, 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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
2,1
|
|
COMMENTS
|
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
|
|
LINKS
|
|
|
EXAMPLE
|
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).
|
|
PROG
|
(Python)
def to_base(n, b):
...s = []
...while n:
......m = n%b
......s = [m]+s
......n = (n-m)//b
...return s
.
def is_palindrome(n):
...return n==n[::-1]
.
def num_palindromes(n, b):
...if n<2:
......return 0
...t = 1
...while is_palindrome(to_base(n**t, b)):
......t+=1
...return t-1
.
def most_palindromes(b):
...return max(range(2, b+1), key=lambda n:num_palindromes(n, b))
(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
vector(100, n, a(n+1)) \\ Derek Orr, Jun 18 2015
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|