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.

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

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 1, 3, 0, 0, 0, 1, 2, 1, 3, 7, 0, 0, 0, 1, 0, 0, 1, 3, 4, 2, 1, 3, 6, 3, 7, 15, 0, 0, 0, 1, 0, 0, 1, 3, 0, 0, 0, 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, 0, 1, 0, 0, 1, 3, 4, 2, 1, 3, 6, 3, 7, 15, 16
Offset: 0

Views

Author

N. J. A. Sloane, Sep 08 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) = 0. See A319419 for a version which represents the empty string by -1.
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. In other words, this is a left inverse to A175046: A318921 o A175046 = A001477 = id on [0..oo). - M. F. Hasler, Sep 10 2018
Conjecture: For n in the range 2^k, ..., 2^(k+1)-1, the total value of a(n) appears to be 2*3^(k-1) - 2^(k-1) (see A027649), and so the average value of a(n) appears to be (3/2)^(k-1) - 1/2. - N. J. A. Sloane, Sep 25 2018
The above conjecture was proved by Doron Zeilberger on Nov 16 2018 (see link) and independently by Chai Wah Wu on Nov 18 2018 (see below). - N. J. A. Sloane, Nov 20 2018
From Chai Wah Wu, Nov 18 2018: (Start)
Conjecture is correct for k > 0. Proof: looking at the least significant 2 bits of n, it is easy to see that a(4n) = 2a(2n), a(4n+1) = a(2n), a(4n+2) = a(2n+1) and a(4n+3) = 2a(2n+1)+1. Define f(k) = Sum_{i=2^k..2^(k+1)-1} a(i), i.e. the sum ranges over all numbers with a (k+1)-bit binary expansion. Thus f(0) = a(1) = 0 and f(1) = a(2)+a(3) = 1. By summing over the recurrence relations for a(n), we get f(k+2) = Sum_{i=2^k..2^(k+1)-1} (f(4i) + f(4i+1) + f(4i+2) + f(4i+3)) = Sum_{i=2^k..2^(k+1)-1} (3a(2i) + 3a(2i+1) + 1) = 3*f(k+1) + 2^k. Solving this first order recurrence relation with the initial condition f(1) = 1 shows that f(k) = 2*3^(k-1)-2^(k-1) for k > 0.
(End)

Examples

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

Crossrefs

Cf. A027649 (average value), A175046, A319419 (a version where a(n)=-1 if the result is the empty string).
See also A319416.

Programs

  • Maple
    r:=proc(n) local t1,t2,L1,len,i,j,k,b1;
    if n <= 2 then return(0); fi;
    b1:=[]; t1:=convert(n,base,2); L1:=nops(t1); p:=1; len:=1;
    for i from 2 to L1 do
    t2:=t1[L1+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(0);
    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)];
  • Mathematica
    a[n_] := FromDigits[Flatten[Rest /@ Split[IntegerDigits[n, 2]]], 2];
    Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Sep 10 2018 *)
  • PARI
    a(n) = if (n==0, 0, n%2==0, my (z=valuation(n,2)); a(n/2^z) * 2^(z-1), my (o=valuation(n+1,2)); (a(n\2^o)+1) * 2^(o-1)-1) \\ Rémy Sigrist, Sep 09 2018
    
  • PARI
    a(n)={forstep(i=#n=binary(n+!n),2,-1,n[i-1]!=n[i] && n=n[^i]); fromdigits(n[^1],2)} \\ For illustration purpose. - M. F. Hasler, Sep 10 2018
    
  • PARI
    A318921(n)=if(n<3, 0, bittest(n, 0), (A318921(n>>n=valuation(n+1, 2))+1)<<(n-1)-1, A318921(n>>n=valuation(n, 2))<<(n-1)) \\ M. F. Hasler, Sep 11 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 0
    print([a(n) for n in range(82)]) # Michael S. Branicky, Jun 01 2025

Formula

a(4n) = 2a(2n), a(4n+1) = a(2n), a(4n+2) = a(2n+1) and a(4n+3) = 2a(2n+1)+1. - Chai Wah Wu, Nov 18 2018

A319416 Cuts-resistance of n: number of applications of Lernormand's "raboter" map needed to transform the binary expansion of n to the empty string.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Sep 21 2018

Keywords

Comments

Here we are using Lenormand's "raboter" map in a stricter sense than in A318921 and A319419. If S is a binary string with successive runs of lengths b,c,d,e,..., the "raboter" map sends S to the binary string with successive runs of lengths b-1,c-1,d-1,e-1,... Runs of length 0 are omitted (they are indicated by dots in the examples below).
To get a(n), start with S equal to the binary expansion of n beginning with the most significant bit, and keep applying the map until we reach the empty string.
After the first step, the string may start with a string of 0's: this is acceptable because we are working with strings, not binary expansions of numbers.
For example, 34 = 100010 -> .00.. = 00 -> 0. = 0 -> . (the empty string), taking 3 steps, so a(34) = 3.
Note: this is not the same as the number of applications of the map k -> A318921(k) needed to reduce the binary expansion of n to zero (because A318921 does not distinguish between 0 and the empty string).
This is also not the same as the number of applications of the map k -> A319419(k) needed to reduce the binary expansion of n to -1 (because A319419 does not distinguish between a string of 0's and a single 0).
The value k appears for the first time when n = 2^k - 1.

Examples

			n: repeatedly applying the map / number of steps = a(n)
0: 0 -> . / 1
1: 1 -> . / 1
2: 10 -> . / 1
3: 11 -> 1 -> . / 2
4: 100 -> 0 -> . / 2
5: 101 -> . / 1
6: 110 -> 1 -> . / 2
7: 111 -> 11 -> 1 -> . / 3
8: 1000 -> 00 -> 0 -> . / 3
9: 1001 -> 0 -> . / 2
10: 1010 -> . / 1
11: 1011 -> 1 -> . / 2
12: 1100 -> 10 -> . / 2
...
		

Crossrefs

Positions of 1's are A000975.
Positions of 2's are A329862.
The version for runs-resistance is A318928.
The version for compositions is A329861.
Binary words counted by cuts-resistance are A319421 or A329860.

Programs

  • Mathematica
    degdep[q_]:=Length[NestWhileList[Join@@Rest/@Split[#]&,q,Length[#]>0&]]-1;
    Table[degdep[IntegerDigits[n,2]],{n,0,50}] (* Gus Wiseman, Nov 25 2019 *)
  • PARI
    a(n) = my (b=binary(n), w=#b); for (k=1, oo, my (ww=0); for (i=2, w, if (b[i-1]==b[i], b[ww++]=b[i])); if (ww==0, return (k), w=ww)) \\ Rémy Sigrist, Sep 23 2018

Extensions

More terms from Rémy Sigrist, Sep 23 2018
Showing 1-2 of 2 results.