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

A162853 Take the binary representation of n. Reduce by one digit every run (completely of either 0's or 1's) of an even number of digits. Increase by one digit every run of an odd number of digits in the binary representation of n (where this added digit has the same value that makes up the rest of the run's digits). a(n) = the decimal equivalent of the result.

Original entry on oeis.org

0, 3, 12, 1, 6, 51, 4, 15, 48, 27, 204, 25, 2, 19, 60, 7, 24, 195, 108, 13, 102, 819, 100, 207, 16, 11, 76, 9, 30, 243, 28, 63, 192, 99, 780, 97, 54, 435, 52, 111, 816, 411, 3276, 409, 50, 403, 828, 103, 8, 67, 44, 5, 38, 307, 36, 79, 240, 123, 972, 121, 14, 115, 252, 31, 96
Offset: 0

Views

Author

Leroy Quet, Jul 14 2009

Keywords

Comments

This is a self-inverse permutation of the nonnegative integers.
Clarification: The consecutive "runs" (mentioned in the definition) alternate between those completely of 1's and those completely of 0's.
In the binary representation of n, replace each run of length r by a run of length A014681(r). - Rémy Sigrist, Oct 09 2018

Examples

			152 in binary is 10011000. There is a run of one 1, followed by a run of two 0's, followed by a run of two 1's, followed by a run of three 0's. We reduce the two runs of two digits each to one digit; and we add a digit (a 1) to the first run of one 1, and a digit (a 0) to the last run of three 0's, to get 11010000. So a(152) is the decimal equivalent of this, which is 208.
		

Crossrefs

Programs

  • Maple
    rerun := proc(L) if nops(L) mod 2 = 0 then subsop(1=NULL,L) ; else [op(L),op(1,L)] ; fi; end: Lton := proc(L) local i; add( op(i,L)*2^(i-1),i=1..nops(L)) ; end: A162853 := proc(n) local strt,en,L,dgs,i; strt := 1; en := -1; L := [] ; dgs := convert(n,base,2) ; for i from 2 to nops(dgs) do if op(i,dgs) <> op(i-1,dgs) then en := i-1 ; L := [op(L), op(rerun([op(strt..en,dgs)])) ] ; strt := i; fi; od: en := nops(dgs) ; L := [op(L), op(rerun([op(strt..en,dgs)])) ] ; Lton(L) ; end: seq(A162853(n),n=1..100) ; # R. J. Mathar, Aug 01 2009
  • Mathematica
    Table[FromDigits[Flatten[If[OddQ[Length[#]],Join[{First[#]},#],Drop[#,1]]& /@Split[ IntegerDigits[ n,2]]], 2],{n,70}] (* Harvey P. Dale, Jun 20 2011 *)
  • PARI
    a(n) = if (n==0, 0, my (b=n%2, r=valuation(n+b,2), rr=if (r%2, r+1, r-1)); (a(n\2^r)+b)*2^rr-b) \\ Rémy Sigrist, Oct 09 2018

Formula

a(n) = A266150(A266151(n)) = A266151(A266150(n)) for any n > 0. - Rémy Sigrist, Oct 09 2018

Extensions

Extended beyond a(13) by R. J. Mathar, Aug 01 2009
a(0) added by Rémy Sigrist, Oct 09 2018

A266150 Take the binary representation of n, increase each run of 0's by one 0 if the length of run is odd, otherwise, if length of run is even, remove one 0. a(n) is the decimal equivalent of the result.

Original entry on oeis.org

0, 1, 4, 3, 2, 9, 12, 7, 16, 5, 36, 19, 6, 25, 28, 15, 8, 33, 20, 11, 18, 73, 76, 39, 48, 13, 100, 51, 14, 57, 60, 31, 64, 17, 132, 67, 10, 41, 44, 23, 144, 37, 292, 147, 38, 153, 156, 79, 24, 97, 52, 27, 50, 201, 204, 103, 112, 29, 228, 115, 30, 121, 124, 63, 32
Offset: 0

Views

Author

Alex Ratushnyak, Dec 21 2015

Keywords

Comments

This is a self-inverse permutation of the positive integers.

Examples

			a(4) = 2 since 4 = 100 binary -> 10 = 2 decimal.
a(5) = 9 since 5 = 101 binary -> 1001 = 9 decimal.
a(6) = 12 since 6 = 110 binary -> 1100 = 12 decimal.
		

Crossrefs

Programs

  • Mathematica
    Table[FromDigits[#, 2] &@ Flatten[If[First@ # == 0, If[OddQ@ Length@ #, Append[IntegerDigits@ #, 0], Most@ IntegerDigits@ #], #] & /@ Split@ IntegerDigits[n, 2]], {n, 64}] (* Michael De Vlieger, Dec 22 2015 *)
  • PARI
    a(n) = if (n==0, 0, my (b=n%2, r=valuation(n+b, 2), rr=if (b, r, r%2, r+1, r-1)); (a(n\2^r)+b)*2^rr-b) \\ Rémy Sigrist, Jan 20 2019

Extensions

a(0) = 0 prepended by Rémy Sigrist, Jan 20 2019
Showing 1-2 of 2 results.