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.

Showing 1-10 of 10 results.

A163617 a(2*n) = 2*a(n), a(2*n + 1) = 2*a(n) + 2 + (-1)^n, for all n in Z.

Original entry on oeis.org

0, 3, 6, 7, 12, 15, 14, 15, 24, 27, 30, 31, 28, 31, 30, 31, 48, 51, 54, 55, 60, 63, 62, 63, 56, 59, 62, 63, 60, 63, 62, 63, 96, 99, 102, 103, 108, 111, 110, 111, 120, 123, 126, 127, 124, 127, 126, 127, 112, 115, 118, 119, 124, 127, 126, 127, 120, 123, 126, 127, 124, 127, 126
Offset: 0

Views

Author

Michael Somos, Aug 01 2009

Keywords

Comments

Fibbinary numbers (A003714) give all integers n >= 0 for which a(n) = 3*n.
From Antti Karttunen, Feb 21 2016: (Start)
Fibbinary numbers also give all integers n >= 0 for which a(n) = A048724(n).
Note that there are also other multiples of three in the sequence, for example, A163617(99) = 231 ("11100111" in binary) = 3*77, while 77 ("1001101" in binary) is not included in A003714. Note that 99 is "1100011" in binary.
(End)

Examples

			G.f. = 3*x + 6*x^2 + 7*x^3 + 12*x^4 + 15*x^5 + 14*x^6 + 15*x^7 + 24*x^8 + 27*x^9 + ...
		

Crossrefs

Programs

Formula

a(n) = -A163618(-n) for all n in ZZ.
Conjecture: a(n) = A003188(n) + (6*n + 1 - (-1)^n)/4. - Velin Yanev, Dec 17 2016

Extensions

Comment about Fibbinary numbers rephrased by Antti Karttunen, Feb 21 2016

A213541 a(n) = n AND n^2, where AND is the bitwise AND operator.

Original entry on oeis.org

0, 1, 0, 1, 0, 1, 4, 1, 0, 1, 0, 9, 0, 9, 4, 1, 0, 1, 0, 1, 16, 17, 4, 17, 0, 17, 0, 25, 16, 9, 4, 1, 0, 1, 0, 1, 0, 1, 36, 33, 0, 1, 32, 41, 0, 41, 4, 33, 0, 33, 0, 33, 16, 49, 36, 17, 0, 49, 32, 25, 16, 9, 4, 1, 0, 1, 0, 1, 0, 1, 4, 1, 64, 65, 64, 73, 0, 9, 68
Offset: 0

Views

Author

Alex Ratushnyak, Jun 14 2012

Keywords

Comments

The graph of this sequence has the shape of a tilted Sierpinski triangle. - WG Zeist, Jan 15 2019

Crossrefs

Cf. A213370.
Cf. A000290.
Cf. A007745 (OR), A169810 (XOR), A002378.

Programs

  • Haskell
    import Data.Bits ((.&.))
    a213541 n = n .&. n ^ 2  -- Reinhard Zumkeller, Apr 25 2013
    
  • Mathematica
    Table[BitAnd[n, n^2], {n, 0, 63}] (* Alonso del Arte, Jun 19 2012 *)
  • PARI
    a(n) = bitand(n, n^2); \\ Michel Marcus, Jan 15 2019
  • Python
    print([n*n & n for n in range(99)])
    

Formula

a(2^k + x) = a(x) + (x^2 AND 2^k) for 0 <= x < 2^k. - David Radcliffe, May 06 2023

A292373 A binary encoding of 3-digits in base-4 representation of n.

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 3, 4, 4, 4, 5, 4, 4, 4, 5, 4, 4, 4, 5, 6, 6, 6, 7, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 3, 4, 4, 4, 5, 4, 4, 4, 5, 4
Offset: 0

Views

Author

Antti Karttunen, Sep 15 2017

Keywords

Examples

			   n      a(n)     base-4(n)  binary(a(n))
                  A007090(n)  A007088(a(n))
  --      ----    ----------  ------------
   1        0          1           0
   2        0          2           0
   3        1          3           1
   4        0         10           0
   5        0         11           0
   6        0         12           0
   7        1         13           1
   8        0         20           0
   9        0         21           0
  10        0         22           0
  11        1         23           1
  12        2         30          10
  13        2         31          10
  14        2         32          10
  15        3         33          11
  16        0        100           0
  17        0        101           0
  18        0        102           0
  19        1        103           1
		

Crossrefs

Programs

  • Python
    def A292373(n): return int(bin(n&n>>1)[:1:-2][::-1],2) # Chai Wah Wu, Jun 30 2022

Formula

a(n) = A059905(A048735(n)) = A059906(A213370(n)).
For all n >= 0, A000120(a(n)) = A160383(n).

A213540 Numbers k such that k AND k*2 = 2, where AND is the bitwise AND operator.

Original entry on oeis.org

3, 11, 19, 35, 43, 67, 75, 83, 131, 139, 147, 163, 171, 259, 267, 275, 291, 299, 323, 331, 339, 515, 523, 531, 547, 555, 579, 587, 595, 643, 651, 659, 675, 683, 1027, 1035, 1043, 1059, 1067, 1091, 1099, 1107, 1155, 1163, 1171, 1187, 1195, 1283, 1291, 1299, 1315
Offset: 1

Views

Author

Alex Ratushnyak, Jun 14 2012

Keywords

Examples

			In binary, 19 is 10011, while 2 * 19 = 38 is of course 100110. Since 010011 AND 100110 = 000010 (in decimal, 2), 19 is in the sequence.
20 is not in the sequence, since 010100 AND 101000 = 000000.
		

Crossrefs

Programs

  • Maple
    F:= combinat[fibonacci]:
    b:= proc(n) local j;
          if n=0 then 0
        else for j from 2 while F(j+1)<=n do od;
             b(n-F(j))+2^(j-2)
          fi
        end:
    a:= n-> 8*b(n-1)+3:
    seq(a(n), n=1..60);  # Alois P. Heinz, Jun 17 2012
  • Mathematica
    Select[Range[1024], BitAnd[#, 2#] == 2 &] (* Alonso del Arte, Jun 18 2012 *)
  • PARI
    is(n)=bitand(n,2*n)==2 \\ Charles R Greathouse IV, Jun 18 2012
  • Python
    for n in range(1777):
        a = 2*n & n
        if a==2:
            print(n, end=',')
    

Formula

a(n) = A003714(n-1)*8 + 3.

A215488 a(0)=1, a(n) = a(n-1) + a(2*n AND n), where AND is the bitwise AND operator.

Original entry on oeis.org

1, 2, 3, 6, 7, 8, 15, 30, 31, 32, 33, 36, 67, 98, 165, 330, 331, 332, 333, 336, 337, 338, 345, 360, 691, 1022, 1353, 1686, 2377, 3068, 5445, 10890, 10891, 10892, 10893, 10896, 10897, 10898, 10905, 10920, 10921, 10922, 10923, 10926, 10957, 10988, 11055, 11220, 22111, 33002
Offset: 0

Views

Author

Alex Ratushnyak, Aug 13 2012

Keywords

Crossrefs

Cf. A213370.

Programs

  • Maple
    f:= proc(n) option remember;
    procname(n-1) + procname(Bits:-And(2*n,n))
    end proc:
    f(0):= 1:
    seq(f(i),i=0..100); # Robert Israel, Dec 29 2016
  • Mathematica
    A215488[n_] := A215488[n] = If[n == 0, 1, A215488[n-1] + A215488[BitAnd[2*n, n]]];
    Array[A215488, 50, 0] (* Paolo Xausa, Aug 06 2025 *)
  • Python
    a = [1]*1000
    for n in range(1,777):
        print(a[n-1], end=', ')
        a[n]= a[n-1] + a[2*n & n]

A229762 a(n) = (n XOR floor(n/2)) AND floor(n/2), where AND and XOR are bitwise logical operators.

Original entry on oeis.org

0, 0, 1, 0, 2, 2, 1, 0, 4, 4, 5, 4, 2, 2, 1, 0, 8, 8, 9, 8, 10, 10, 9, 8, 4, 4, 5, 4, 2, 2, 1, 0, 16, 16, 17, 16, 18, 18, 17, 16, 20, 20, 21, 20, 18, 18, 17, 16, 8, 8, 9, 8, 10, 10, 9, 8, 4, 4, 5, 4, 2, 2, 1, 0, 32, 32, 33, 32, 34, 34, 33, 32, 36, 36, 37, 36, 34, 34, 33
Offset: 0

Views

Author

Alex Ratushnyak, Sep 28 2013

Keywords

Comments

a(n) has a 01 bit pair in place of each 10 bit pair in n, and everywhere else 0 bits. Or equivalently a(n) has a 1-bit immediately below each run of 1's in n, but excluding a run ending at the least significant bit since below that is below the radix point. - Kevin Ryde, Feb 27 2021

Examples

			From _Kevin Ryde_, Feb 27 2021: (Start)
     n = 7267 = binary 1110001100011
  a(n) =  528 = binary   01000010000   1-bit below each run
(End)
		

Crossrefs

Cf. A003188 (n XOR floor(n/2)).
Cf. A048724 (n XOR (n*2)).
Cf. A048735 (n AND floor(n/2)).
Cf. A213370 (n AND (n*2)).
Cf. A213064 (n XOR (n*2) AND (n*2), 1-bit above each run).
Cf. A229763 ((2*n) XOR n AND n, low 1-bit each run).

Programs

  • Haskell
    import Data.Bits ((.&.), xor, shiftR)
    a229762 n = (n `xor` shiftR n 1) .&. shiftR n 1 :: Int
    -- Reinhard Zumkeller, Oct 10 2013
    
  • PARI
    a(n) = bitnegimply(n>>1,n); \\ Kevin Ryde, Feb 27 2021
  • Python
    for n in range(333): print (n ^ (n>>1)) & (n>>1),
    
  • Python
    def A229762(n): return ~n& n>>1 # Chai Wah Wu, Jun 29 2022
    

Formula

a(n) = (n XOR floor(n/2)) AND floor(n/2) = (n AND floor(n/2)) XOR floor(n/2).
a(n) = floor(n/2) AND NOT n. - Chai Wah Wu, Jun 29 2022

A229763 a(n) = (2*n) XOR n AND n, where AND and XOR are bitwise logical operators.

Original entry on oeis.org

0, 1, 2, 1, 4, 5, 2, 1, 8, 9, 10, 9, 4, 5, 2, 1, 16, 17, 18, 17, 20, 21, 18, 17, 8, 9, 10, 9, 4, 5, 2, 1, 32, 33, 34, 33, 36, 37, 34, 33, 40, 41, 42, 41, 36, 37, 34, 33, 16, 17, 18, 17, 20, 21, 18, 17, 8, 9, 10, 9, 4, 5, 2, 1, 64, 65, 66, 65, 68, 69, 66, 65, 72, 73, 74
Offset: 0

Views

Author

Alex Ratushnyak, Sep 28 2013

Keywords

Comments

a(n) is the least significant 1-bit of each run of consecutive 1's in n, and everywhere else 0's. Or equivalently, clear to 0 each 1-bit which has another 1 immediately below. - Kevin Ryde, Feb 27 2021

Examples

			From _Kevin Ryde_, Feb 27 2021: (Start)
     n = 1831 = binary 11100100111
  a(n) =  289 = binary   100100001   low 1-bit each run
(End)
		

Crossrefs

Cf. A003188 (n XOR floor(n/2)).
Cf. A048724 (n XOR (n*2)).
Cf. A048735 (n AND floor(n/2)).
Cf. A213370 (n AND (n*2)).
Cf. A213064 (n XOR (n*2) AND (n*2)).
Cf. A229762 (n XOR floor(n/2) AND floor(n/2), 1-bit below each run).
Cf. A292272 (high 1-bit each run).

Programs

  • Haskell
    import Data.Bits ((.&.), xor, shiftL)
    a229763 n = (shiftL n 1 `xor` n) .&. n :: Int
    -- Reinhard Zumkeller, Oct 10 2013
    
  • Mathematica
    Array[BitAnd[BitXor[2 #, #], #] &, 75, 0] (* Michael De Vlieger, Nov 03 2022 *)
  • PARI
    a(n) = bitnegimply(n,n<<1); \\ Kevin Ryde, Feb 27 2021
  • Python
    for n in range(333): print (2*n ^ n) & n,
    
  • Python
    def A229763(n): return n&~(n<<1) # Chai Wah Wu, Jun 29 2022
    

Formula

a(n) = ((2*n) XOR n) AND n = ((2*n) AND n) XOR n.
a(2n) = 2a(n), a(2n+1) = A229762(n). - Ralf Stephan, Oct 07 2013
a(n) = n AND NOT 2n. - Chai Wah Wu, Jun 29 2022
G.f.: x/(1 - x^2) + Sum_{k>=1}(2^k*x^(2^k)/((1 - x)*(1 + x^(2^k))*(1 + x^(2^(k - 1))))). - Miles Wilson, Jan 24 2025

A334076 a(n) = bitwise NOR of n and 2n.

Original entry on oeis.org

0, 0, 1, 0, 3, 0, 1, 0, 7, 4, 1, 0, 3, 0, 1, 0, 15, 12, 9, 8, 3, 0, 1, 0, 7, 4, 1, 0, 3, 0, 1, 0, 31, 28, 25, 24, 19, 16, 17, 16, 7, 4, 1, 0, 3, 0, 1, 0, 15, 12, 9, 8, 3, 0, 1, 0, 7, 4, 1, 0, 3, 0, 1, 0, 63, 60, 57, 56, 51, 48, 49, 48, 39, 36, 33, 32, 35, 32, 33
Offset: 0

Views

Author

Alois P. Heinz, Apr 13 2020

Keywords

Comments

Exactly all bits that are 0 in both parameters (but not a leading 0 of both) are set to 1 in the output of bitwise NOR.

Crossrefs

Programs

  • Maple
    a:= n-> Bits[Nor](n, 2*n):
    seq(a(n), n=0..127);
  • PARI
    a(n) = my(x=bitor(n, 2*n)); bitneg(x, #binary(x)); \\ Michel Marcus, Apr 14 2020
  • Python
    def A334076(n):
        m = n|(2*n)
        return 0 if n == 0 else 2**(len(bin(m))-2)-1-m # Chai Wah Wu, Apr 14 2020
    

Formula

a(n) = 0 <=> n in { A247648 } union { 0 }.
a(n) = n-1 <=> n in { A000079 }.
a(n) = n/2 <=> n in { A125835 }.
a(n) = n*3/4 <=> n in { A141032 }.

A344180 Lexicographically earliest infinite sequence such that a(i) = a(j) => f(i) = f(j) for all i, j >= 0, where f(n) = 0 if n is a Fibbinary number (A003714), otherwise f(n) = n.

Original entry on oeis.org

1, 1, 1, 2, 1, 1, 3, 4, 1, 1, 1, 5, 6, 7, 8, 9, 1, 1, 1, 10, 1, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 1, 1, 21, 1, 1, 22, 23, 1, 1, 1, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 1, 1, 1, 45, 1, 1, 46, 47, 1, 1, 1, 48, 49, 50, 51, 52, 1, 1, 1, 53, 1, 1, 54, 55, 56, 57
Offset: 0

Views

Author

Antti Karttunen, May 16 2021

Keywords

Comments

For all i, j:
a(i) = a(j) => A085357(i) = A085357(j),
a(i) = a(j) => A213370(i) = A213370(j),
a(i) = a(j) => A344182(i) = A344182(j).

Crossrefs

Cf. A003714 (positions of 1's), A085357, A213370, A344182.
Cf. also A324400.

Programs

  • PARI
    up_to = 65537;
    rgs_transform(invec) = { my(om = Map(), outvec = vector(length(invec)), u=1); for(i=1, length(invec), if(mapisdefined(om,invec[i]), my(pp = mapget(om, invec[i])); outvec[i] = outvec[pp] , mapput(om,invec[i],i); outvec[i] = u; u++ )); outvec; };
    Aux344180(n) = if(!bitand(n,n+n),0,n);
    v344180 = rgs_transform(vector(1+up_to,n,Aux344180(n-1)));
    A344180(n) = v344180[1+n];

A387269 Numbers whose binary expansion consists of alternating runs of 1's and 0's where each run of 0's is exactly one longer than the preceding run of 1's, and the expansion ends with a 0-run.

Original entry on oeis.org

4, 24, 36, 112, 152, 196, 292, 480, 624, 792, 900, 1176, 1220, 1572, 1984, 2340, 2528, 3184, 3608, 3844, 4720, 4888, 4996, 6296, 6340, 7204, 8064, 9368, 9412, 9764, 10176, 12580, 12768, 14448, 15384, 15876, 18724, 18912, 19568, 19992, 20228, 25200, 25368, 25476
Offset: 1

Views

Author

Ahmet Caglar Saygili, Aug 24 2025

Keywords

Comments

Every term is even (since the binary ends with a 0-run).
Writing the binary word as consecutive pairs 1^{a_1}0^{a_1+1}1^{a_2}0^{a_2+1} ..., the total number of 0's exceeds the total number of 1's by the number of pairs.
Single-pair subfamily 1^{k}0^{k+1}_2, with k >= 1, is A059153(k-1).
Let f(n) = n & (2n) (bitwise AND; A213370). If x has binary run pairs 1^{L_i+1}0^{L_i} (MSB->LSB) as in A387270, then f(x) has pairs 1^{L_i}0^{L_i+1}. Thus f maps A387270 bijectively onto this sequence. Reason: n & (2n) has 1-bits exactly where n has adjacent 1-bits, which shortens every 1-run by 1 and lengthens the following 0-run by 1. Conversely, g(n) = n | floor(n/2) increases each 1-run by 1 and shortens the following 0-run by 1, mapping this sequence back to A387270. Examples: f(6) = 4 (110_2 -> 100_2), f(28) = 24 (11100_2 -> 11000_2); g(24) = 28 (11000_2 -> 11100_2), g(36) = 54 (100100_2 -> 110110_2).

Examples

			36 = 100100_2 is a term since its pairs of (1 then 0) runs are (1,2), (1,2).
		

Crossrefs

Programs

  • Julia
    function ok(n::Integer)::Bool
        n > 0 && iseven(n) || return false
        x = unsigned(n)
        while x != 0
            z = trailing_zeros(x); x >>= z
            o = trailing_ones(x)
            z == o + 1 || return false
            x >>= o
        end
        true
    end
    [k for k in 0:10^5 if ok(k)]
    
  • PARI
    isok(k) = if (!(k%2), my(b=binary(k), pos=1, d, dd); for (i=1, #b-1, if (b[i] != b[i+1], if (b[i], d = i-pos+1; pos = i+1, dd = i-pos+1; pos = i+1; if (dd != d+1, return(0))))); dd = #b - pos+1; if (dd != d+1, return(0)); return(1);); \\ Michel Marcus, Aug 26 2025
  • Python
    from itertools import groupby
    def ok(n):
        L = [len(list(g)) for k, g in groupby(bin(n)[2:])]
        return (m:=len(L))&1 == 0 and all(L[2*j]+1 == L[2*j+1] for j in range(m>>1))
    print([k for k in range(10**5) if ok(k)]) # Michael S. Branicky, Aug 25 2025
    
Showing 1-10 of 10 results.