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-3 of 3 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

A106151 In binary representation of n: delete one zero in each contiguous block of zeros.

Original entry on oeis.org

1, 1, 3, 2, 3, 3, 7, 4, 5, 3, 7, 6, 7, 7, 15, 8, 9, 5, 11, 6, 7, 7, 15, 12, 13, 7, 15, 14, 15, 15, 31, 16, 17, 9, 19, 10, 11, 11, 23, 12, 13, 7, 15, 14, 15, 15, 31, 24, 25, 13, 27, 14, 15, 15, 31, 28, 29, 15, 31, 30, 31, 31, 63, 32, 33, 17, 35, 18, 19, 19, 39, 20, 21, 11, 23, 22, 23
Offset: 1

Views

Author

Reinhard Zumkeller, May 07 2005

Keywords

Comments

Equivalently, change bits 10 -> 0. - Michael S. Branicky, Nov 12 2021

Examples

			n=144 = '10010000' -> '101000' = 40 = a(144);
n=145 = '10010001' -> '101001' = 41 = a(145);
n=146 = '10010010' -> '10101'  = 21 = a(146).
		

Crossrefs

Programs

  • Haskell
    import Data.List (group)
    a106151 = foldr (\b v -> 2 * v + b) 0 . concatMap
       (\bs'@(b:bs) -> if b == 0 then bs else bs') . group . a030308_row
    -- Reinhard Zumkeller, Jul 05 2013
    
  • PARI
    A106151(n) = if(n<=1, n, if(n%2, 1+(2*A106151((n-1)/2)), A106151(n>>valuation(n, 2))<<(valuation(n, 2)-1))); \\ Antti Karttunen, May 13 2018
    
  • PARI
    A106151(n) = { my(s=0, i=0); while(n, if(2!=(n%4), s += (n%2)<>= 1); (s); }; \\ Antti Karttunen, Jul 01 2024
    
  • Python
    def a(n): return int(bin(n).replace("b", "").replace("10", "1"), 2)
    print([a(n) for n in range(1, 78)]) # Michael S. Branicky, Nov 12 2021

Formula

a(n) <= n; a(n) = n iff n = 2^k-1: a(A000225(n))=A000225(n);
A000120(a(n)) = A000120(n);
A023416(a(n)) = A023416(n) - A087116(n).
a(n) = b(n, 0), where b(n, r) = if n = 1 then 1 else b(floor(n/2), 1 - n mod 2)*(1 + floor((1 + r + n mod 2)/2)) + n mod 2.
For n <= 1, a(n) = n, and for n > 1, if n is odd, then a(n) = 1+2*a((n-1)/2), otherwise, when n is even, a(n) = (2^(A007814(n)-1)) * a(A000265(n)). - Antti Karttunen, May 13 2018

A090077 In binary expansion of n: reduce contiguous blocks of 1's to 1.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Nov 20 2003

Keywords

Examples

			100 -> '1100100' -> [11]00[1]00 -> [1]00[1]00 -> '100100' -> 36=a(100).
		

Crossrefs

Programs

  • Mathematica
    Array[FromDigits[Flatten[Split@ IntegerDigits[#, 2] /. w_List /; First[w] == 1 -> {1}], 2] &, 80, 0] (* Michael De Vlieger, Jul 28 2022 *)
  • Python
    def a(n):
        b = bin(n)[2:]
        while "11" in b: b = b.replace("11", "1")
        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(A090078(n)) = A090078(a(n)) = A090079(n).
a(A003714(n)) = A003714(n); a(A004780(n)) < A004780(n); a(n) <= A179821(n); A085357(a(n)) = 1. - Reinhard Zumkeller, Jul 31 2010
Showing 1-3 of 3 results.