login
Palindromes in base 4 (written in base 4).
10

%I #23 Jun 15 2024 01:02:29

%S 0,1,2,3,11,22,33,101,111,121,131,202,212,222,232,303,313,323,333,

%T 1001,1111,1221,1331,2002,2112,2222,2332,3003,3113,3223,3333,10001,

%U 10101,10201,10301,11011,11111,11211,11311,12021,12121,12221,12321,13031

%N Palindromes in base 4 (written in base 4).

%C 2*a(n) and 3*a(n) give palindromes in base 10 for any n. - _Arkadiusz Wesolowski_, Jun 22 2012

%C Equivalently, palindromes k (written in base 10) such that 3*k is a palindrome. - _Bruno Berselli_, Sep 12 2018

%t (* get NextPalindrome from A029965 *) Select[NestList[NextPalindrome, 0, 290], Max@IntegerDigits@# < 4 &] (* _Robert G. Wilson v_, May 09 2006 *)

%o (Python)

%o from gmpy2 import digits

%o def A118595(n):

%o if n == 1: return 0

%o y = (x:=1<<(n.bit_length()-2&-2))<<2

%o 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

%Y Cf. A014192, A057148, A118594, A118595, A118596, A118597, A118598, A118599, A118600, A002113.

%K nonn,base

%O 1,3

%A _Martin Renner_, May 08 2006

%E More terms from _Robert G. Wilson v_, May 09 2006