cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A063695 Remove even-positioned bits from the binary expansion of n.

Original entry on oeis.org

0, 0, 2, 2, 0, 0, 2, 2, 8, 8, 10, 10, 8, 8, 10, 10, 0, 0, 2, 2, 0, 0, 2, 2, 8, 8, 10, 10, 8, 8, 10, 10, 32, 32, 34, 34, 32, 32, 34, 34, 40, 40, 42, 42, 40, 40, 42, 42, 32, 32, 34, 34, 32, 32, 34, 34, 40, 40, 42, 42, 40, 40, 42, 42, 0, 0, 2, 2, 0, 0, 2, 2, 8, 8, 10, 10, 8, 8, 10, 10, 0, 0
Offset: 0

Views

Author

Antti Karttunen, Aug 03 2001

Keywords

Comments

In the base 4 expansion of n, change 1 to 0 and 3 to 2. - Paolo Xausa, Feb 27 2025

Examples

			a(25) = 8 because 25 = 11001 in binary and when we AND this with 1010 we are left with 1000 = 8.
		

Crossrefs

Cf. A004514 (bisection), A063694 (remove odd-positioned bits), A090569.

Programs

  • Haskell
    a063695 0 = 0
    a063695 n = 4 * a063695 n' + 2 * div q 2
                where (n', q) = divMod n 4
    -- Reinhard Zumkeller, Sep 26 2015
    
  • Maple
    [seq(every_other_pos(j,2,1),j=0..120)]; # Function every_other_pos given at A063694.
  • Mathematica
    A063695[n_] := FromDigits[ReplaceAll[IntegerDigits[n, 4], {1 -> 0, 3 -> 2}], 4];
    Array[A063695, 100, 0] (* Paolo Xausa, Feb 27 2025 *)
  • Python
    def A063695(n): return n&((1<<(m:=n.bit_length())+(m&1^1))-1)//3 # Chai Wah Wu, Jan 30 2023

Formula

a(n) + A063694(n) = n.
a(n) = 2*(floor(n/2)-a(floor(n/2))). - Vladeta Jovovic, Feb 23 2003
From Ralf Stephan, Oct 06 2003: (Start)
G.f. 1/(1-x) * Sum_{k>=0} (-2)^k*2t^2/(1-t^2) where t = x^2^k.
Members of A004514 written twice.
(End)
a(n) = 4 * a(floor(n / 4)) + 2 * floor(n mod 4 / 2). - Reinhard Zumkeller, Sep 26 2015
a(n) = A090569(n+1)-1. - R. J. Mathar, Jun 22 2020
a(n) = 2*(n - A380110(n)). - Paolo Xausa, Feb 27 2025