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.

A319419 In binary expansion of n, delete one symbol from each run. Set a(n)=-1 if the result is the empty string.

Original entry on oeis.org

-1, -1, -1, 1, 0, -1, 1, 3, 0, 0, -1, 1, 2, 1, 3, 7, 0, 0, 0, 1, 0, -1, 1, 3, 4, 2, 1, 3, 6, 3, 7, 15, 0, 0, 0, 1, 0, 0, 1, 3, 0, 0, -1, 1, 2, 1, 3, 7, 8, 4, 2, 5, 2, 1, 3, 7, 12, 6, 3, 7, 14, 7, 15, 31, 0, 0, 0, 1, 0, 0, 1, 3, 0, 0, 0, 1, 2, 1, 3, 7, 0, 0
Offset: 0

Views

Author

N. J. A. Sloane, Sep 21 2018

Keywords

Comments

If the binary expansion of n is 1^b 0^c 1^d 0^e ..., then a(n) is the number whose binary expansion is 1^(b-1) 0^(c-1) 1^(d-1) 0^(e-1) .... Leading 0's are omitted, and if the result is the empty string, here we set a(n) = -1. See A318921 for a version which represents the empty string by 0.
Lenormand refers to this operation as planing ("raboter") the runs (or blocks) of the binary expansion.
A175046 expands the runs in a similar way, and a(A175046(n)) = A001477(n). - Andrew Weimholt, Sep 08 2018 (Comment copied from A318921.)
a(n) = -1 iff n in A000975.

Examples

			n / "planed" string / a(n)
0 e -1 (e = empty string)
1 e -1
10 e -1
11 1 1
100 0 0
101 e -1
110 1 1
111 11 3
1000 00 0
1001 0 0
1010 e -1
1011 1 1
1100 10 2
1101 1 1
1110 11 3
1111 111 7
10000 000 0
...
		

Crossrefs

Programs

  • Maple
    r:=proc(n) local t1, t2, L, len, i, j, k, b1;
    if n <= 2 then return(-1); fi;
    b1:=[]; t1:=convert(n, base, 2); L:=nops(t1); p:=1; len:=1;
    for i from 2 to L do
    t2:=t1[L+1-i];
    if (t2=p) and (i1 then for j from 1 to len-1 do b1:=[op(b1), p]; od: fi;
       p:=t2; len:=1;
    fi;               od;
    if nops(b1)=0 then return(-1);
    else k:=b1[1];
    for i from 2 to nops(b1) do k:=2*k+b1[i]; od;
    return(k);
    fi;
    end;
    [seq(r(n), n=0..120)];
  • Python
    from re import split
    def A319419(n):
        s = ''.join(d[:-1] for d in split('(0+)|(1+)',bin(n)[2:]) if d not in {'','0','1',None})
        return -1 if s == '' else int(s,2) # Chai Wah Wu, Sep 24 2018
    
  • Python
    from itertools import groupby
    def a(n):
        s = "".join(k*(len(list(g))-1) for k, g in groupby(bin(n)[2:]))
        return int(s, 2) if s != "" else -1
    print([a(n) for n in range(82)]) # Michael S. Branicky, Jun 01 2025