OFFSET
1,3
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..1457
MATHEMATICA
(* get NextPalindrome from A029965 *) Select[NestList[NextPalindrome, 0, 62], Max@IntegerDigits@# < 9 &] (* Robert G. Wilson v, May 09 2006 *)
PROG
(Python)
from gmpy2 import digits
def palgenbase(l, b): # generator of palindromes in base b <=10 of length <= 2*l, written in base b
if l > 0:
yield 0
for x in range(1, l+1):
for y in range(b**(x-1), b**x):
s = digits(y, b)
yield int(s+s[-2::-1])
for y in range(b**(x-1), b**x):
s = digits(y, b)
yield int(s+s[::-1])
A118600_list = list(palgenbase(3, 9)) # Chai Wah Wu, Dec 01 2014
(Python)
from sympy import integer_log
from gmpy2 import digits
def A118600(n):
if n == 1: return 0
y = 9*(x:=9**integer_log(n>>1, 9)[0])
return int((s:=digits(n-x, 9))+s[-2::-1] if n<x+y else (s:=digits(n-y, 9))+s[::-1]) # Chai Wah Wu, Jun 14 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Martin Renner, May 08 2006
EXTENSIONS
More terms from Robert G. Wilson v, May 09 2006
STATUS
approved