login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A048703 Numbers which in base 4 are palindromes and have an even number of digits. 4
0, 5, 10, 15, 65, 85, 105, 125, 130, 150, 170, 190, 195, 215, 235, 255, 1025, 1105, 1185, 1265, 1285, 1365, 1445, 1525, 1545, 1625, 1705, 1785, 1805, 1885, 1965, 2045, 2050, 2130, 2210, 2290, 2310, 2390 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,2
COMMENTS
In quaternary base (base 4) the terms look like 0, 11, 22, 33, 1001, 1111, 1221, 1331, 2002, 2112, 2222, 2332, 3003, 3113, 3223, 3333, 100001, 101101, 102201, ..., which is a subsequence of A118595.
Zero is included as a(0) because we can consider it as having zero digits after leading zeros have been excluded.
LINKS
FORMULA
a(0) = 0, and for n >= 1, a(n) = A030103(n) + (n * A000302(A110591(n))). - Antti Karttunen, Oct 30 2013
a(n) = 5*A048704(n). [This is just a consequence of the definition of A048704.] - Antti Karttunen, Jul 25 2013
EXAMPLE
Each a(n) is obtained by concatenating the original base-4 expansion of n (which comes to the left hand, i.e., the most significant side) with its mirror-image (which comes to the right hand, i.e., the least significant side). For example, for a(4) we have 4 = '10' in base 4, which concatenated with its reversal '01' yields '1001', which when converted back to decimal yields 1*64 + 0*16 + 0*4 + 1*1 = 65, thus a(4)=65.
MAPLE
A048703(n) := (n) -> (2^(floor_log_2_coarse(n)+1))*n + sum('(bit_i(n, i+((-1)^i))*(2^(floor_log_2_coarse(n)-i)))', 'i'=0..floor_log_2_coarse(n));
bit_i := (x, i) -> `mod`(floor(x/(2^i)), 2);
# Following is like floor_log_2 but even results are incremented by one:
floor_log_2_coarse := proc(n) local nn, i: nn := n; for i from -1 to n do if(0 = nn) then RETURN(i+(1-(i mod 2))); fi: nn := floor(nn/2); od: end:
PROG
(MIT/GNU Scheme)
(define (A048703 n) (if (zero? n) n (let ((uplim (+ (A000523 n) (- 1 (modulo (A000523 n) 2))))) (+ (* (expt 2 (+ 1 uplim)) n) (add (lambda (i) (* (bit_i n (+ i (expt -1 i))) (expt 2 (- uplim i)))) 0 uplim)))))
(define (bit_i n i) (modulo (floor->exact (/ n (expt 2 i))) 2))
;; The functional add implements sum_{i=lowlim..uplim} intfun(i):
(define (add intfun lowlim uplim) (let sumloop ((i lowlim) (res 0)) (cond ((> i uplim) res) (else (sumloop (1+ i) (+ res (intfun i)))))))
;; Another version based on using A030103:
(define (A048703v2 n) (if (zero? n) n (+ (* (A000302 (A110591 n)) n) (A030103 n))))
(Python)
def A048703(n):
s = bin(n-1)[2:]
if len(s) % 2: s = '0'+s
t = [s[i:i+2] for i in range(0, len(s), 2)]
return int(''.join(t+t[::-1]), 2) # Chai Wah Wu, Feb 26 2021
CROSSREFS
Subsequence of A014192 (all numbers which are palindromes in base 4, including also those of odd number of digits).
Cf. also A048704 (this sequence divided by 5), A048701 (binary palindromes of even length), A055948, A110591, A118595, A030103, A007090, A000302.
Sequence in context: A022600 A067237 A196157 * A020332 A244025 A044830
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Mar 07 1999
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 18 18:58 EDT 2024. Contains 371781 sequences. (Running on oeis4.)