login
A118600
Palindromes in base 9 (written in base 9).
9
0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 22, 33, 44, 55, 66, 77, 88, 101, 111, 121, 131, 141, 151, 161, 171, 181, 202, 212, 222, 232, 242, 252, 262, 272, 282, 303, 313, 323, 333, 343, 353, 363, 373, 383, 404, 414, 424, 434, 444, 454, 464, 474, 484, 505, 515, 525, 535, 545
OFFSET
1,3
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
KEYWORD
nonn,base
AUTHOR
Martin Renner, May 08 2006
EXTENSIONS
More terms from Robert G. Wilson v, May 09 2006
STATUS
approved