login
A118595
Palindromes in base 4 (written in base 4).
10
0, 1, 2, 3, 11, 22, 33, 101, 111, 121, 131, 202, 212, 222, 232, 303, 313, 323, 333, 1001, 1111, 1221, 1331, 2002, 2112, 2222, 2332, 3003, 3113, 3223, 3333, 10001, 10101, 10201, 10301, 11011, 11111, 11211, 11311, 12021, 12121, 12221, 12321, 13031
OFFSET
1,3
COMMENTS
2*a(n) and 3*a(n) give palindromes in base 10 for any n. - Arkadiusz Wesolowski, Jun 22 2012
Equivalently, palindromes k (written in base 10) such that 3*k is a palindrome. - Bruno Berselli, Sep 12 2018
MATHEMATICA
(* get NextPalindrome from A029965 *) Select[NestList[NextPalindrome, 0, 290], Max@IntegerDigits@# < 4 &] (* Robert G. Wilson v, May 09 2006 *)
PROG
(Python)
from gmpy2 import digits
def A118595(n):
if n == 1: return 0
y = (x:=1<<(n.bit_length()-2&-2))<<2
return int((s:=digits(n-x, 4))+s[-2::-1] if n<x+y else (s:=digits(n-y, 4))+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