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-4 of 4 results.

A090079 In binary expansion of n: reduce contiguous blocks of 0's to 0 and contiguous blocks of 1's to 1.

Original entry on oeis.org

0, 1, 2, 1, 2, 5, 2, 1, 2, 5, 10, 5, 2, 5, 2, 1, 2, 5, 10, 5, 10, 21, 10, 5, 2, 5, 10, 5, 2, 5, 2, 1, 2, 5, 10, 5, 10, 21, 10, 5, 10, 21, 42, 21, 10, 21, 10, 5, 2, 5, 10, 5, 10, 21, 10, 5, 2, 5, 10, 5, 2, 5, 2, 1, 2, 5, 10, 5, 10, 21, 10, 5, 10, 21, 42, 21, 10, 21, 10, 5, 10, 21, 42, 21
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 20 2003

Keywords

Comments

a(a(n))=a(n); a(n)=A090078(A090077(n))=A090077(A090078(n)).
All terms are without consecutive equal binary digits: a(A000975(n)) = A000975(n) and a(m) <> A000975(n) for m < A000975(n). - Reinhard Zumkeller, Feb 16 2013

Examples

			100 -> '1100100' -> [11][00][1][00] -> [1][0][1][0] -> '1010' ->
10=a(100).
		

Crossrefs

Programs

  • Haskell
    a090079 = foldr (\b v -> 2 * v + b) 0 . map head . group . a030308_row
    -- Reinhard Zumkeller, Feb 16 2013
    
  • Mathematica
    Table[FromDigits[#, 2] &@ Map[First, Split@ IntegerDigits[n, 2]], {n, 0, 83}] (* Michael De Vlieger, Dec 12 2016 *)
    FromDigits[Split[IntegerDigits[#,2]][[All,1]],2]&/@Range[0,90] (* Harvey P. Dale, Oct 10 2017 *)
  • Python
    from itertools import groupby
    def a(n): return int("".join(k for k, g in groupby(bin(n)[2:])), 2)
    print([a(n) for n in range(84)]) # Michael S. Branicky, Jul 23 2022

Formula

Conjecture: a(n) = (2^(A005811(n)+1) + (1-(-1)^n)/2 - 2)/3. - Velin Yanev, Dec 12 2016

A090078 In binary expansion of n, reduce contiguous blocks of 0's to 0.

Original entry on oeis.org

0, 1, 2, 3, 2, 5, 6, 7, 2, 5, 10, 11, 6, 13, 14, 15, 2, 5, 10, 11, 10, 21, 22, 23, 6, 13, 26, 27, 14, 29, 30, 31, 2, 5, 10, 11, 10, 21, 22, 23, 10, 21, 42, 43, 22, 45, 46, 47, 6, 13, 26, 27, 26, 53, 54, 55, 14, 29, 58, 59, 30, 61, 62, 63, 2, 5, 10, 11, 10, 21, 22, 23, 10, 21
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 20 2003

Keywords

Examples

			100 -> '1100100' -> 11[00]1[00] -> 11[0]1[0] -> '11010' -> 26=a(100).
		

Crossrefs

Programs

  • Mathematica
    a[n_] := FromDigits[Flatten[Split[IntegerDigits[n, 2]] /. x_List /; x[[1]] == 0 -> {0}], 2]; Array[a, 100, 0] (* Amiram Eldar, Jul 30 2025 *)
  • PARI
    a(n)=my(v=binary(n),t); for(i=1,#v, if(v[i], t+=t+1, t%2, t+=t)); t \\ Charles R Greathouse IV, Aug 17 2016
    
  • Python
    def a(n):
        b = bin(n)[2:]
        while "00" in b: b = b.replace("00", "0")
        return int(b, 2)
    print([a(n) for n in range(81)]) # Michael S. Branicky, Jul 27 2022

Formula

a(a(n)) = a(n).
a(A090077(n)) = A090077(a(n)) = A090079(n).

A179821 In binary representation of n: replace all blocks of k contiguous ones with binary representation of k.

Original entry on oeis.org

0, 1, 2, 2, 4, 5, 4, 3, 8, 9, 10, 10, 8, 9, 6, 4, 16, 17, 18, 18, 20, 21, 20, 11, 16, 17, 18, 18, 12, 13, 8, 5, 32, 33, 34, 34, 36, 37, 36, 19, 40, 41, 42, 42, 40, 41, 22, 20, 32, 33, 34, 34, 36, 37, 36, 19, 24, 25, 26, 26, 16, 17, 10, 6, 64, 65, 66, 66, 68, 69, 68, 35, 72, 73, 74, 74
Offset: 0

Views

Author

Reinhard Zumkeller, Jul 31 2010

Keywords

Comments

a(n) <= n:
a(A003714(n)) = A003714(n); a(A004780(n)) < A004780(n);
A090077(n) <= a(n).

Examples

			n=45->101101->[1]0[11]0[1]->[1]0[2]0[1]->[1]0[10]0[1]->101001->a(45)=41.
		

Crossrefs

Formula

a(2*n) = 2*a(n); a(4*n+1) = 4*a(n)+1.

A348710 In the binary expansion of n, decrease the length of each run of 1-bits by one.

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 2, 3, 0, 0, 0, 1, 4, 2, 6, 7, 0, 0, 0, 1, 0, 0, 2, 3, 8, 4, 4, 5, 12, 6, 14, 15, 0, 0, 0, 1, 0, 0, 2, 3, 0, 0, 0, 1, 4, 2, 6, 7, 16, 8, 8, 9, 8, 4, 10, 11, 24, 12, 12, 13, 28, 14, 30, 31, 0, 0, 0, 1, 0, 0, 2, 3, 0, 0, 0, 1, 4, 2, 6, 7, 0, 0, 0
Offset: 0

Views

Author

Kevin Ryde, Oct 30 2021

Keywords

Comments

Equivalently, change bits 01 -> 0, including a 0 reckoned above the most significant 1-bit of n so change there.
A single 1-bit run decreases to nothing. The Fibbinary numbers (A003714) are those n with only single 1-bits so that a(n) = 0 iff n is in A003714.
a(n) = 1 iff n is in A213540 since those values end with bits 011 (which become 01) and otherwise have only single 1-bits, as do the Fibbinary numbers.
Decreasing each run is the inverse of the increase A175048 so that a(A175048(k)) = k. This n = A175048(k) is the smallest n with a(n) = k and then other occurrences of k are by inserting single 1-bits into this n, including anywhere above the most significant bit.

Examples

			n    = 14551 = binary 111 000 11 0 1 0 111
a(n) =   787 = binary  11 000  1 0   0  11
		

Crossrefs

Cf. A007088 (binary), A175048 (increase 1-bits), A090077 (decrease to single 1-bits).
Cf. A003714 (indices of 0's), A213540 (indices of 1's).
Cf. A106151 (decrease 0-bits), A318921 (decrease each run).

Programs

  • Mathematica
    Table[FromDigits[Flatten[Split@IntegerDigits[n,2]/. {1,a___}:>{a}],2],{n,0,82}] (* Giorgos Kalogeropoulos, Nov 01 2021 *)
  • PARI
    a(n) = my(v=binary(n),t=0); for(i=2,#v, if(v[i-1]||!v[i], v[t++]=v[i])); fromdigits(v[1..t],2);
    
  • Python
    def a(n): return int(bin(n).replace("b", "").replace("01", "0"), 2)
    print([a(n) for n in range(83)]) # Michael S. Branicky, Oct 31 2021
Showing 1-4 of 4 results.