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.

Previous Showing 11-17 of 17 results.

A089310 Write n in binary; a(n) = number of 1's in second block of 1's from right.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Dec 22 2003

Keywords

Examples

			13 = 1101 so a(13) = 2.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local t,q,r;
      r:= 0: t:= n;
      while t::even do t:= t/2 od;
      while t::odd do t:= (t-1)/2 od;
      if t = 0 then return 0 fi;
      while t::even do t:= t/2 od;
      while t::odd do r:= r+1; t:= (t-1)/2 od;
      r
    end proc:
    f(0):= 0:
    map(f, [$0..100]); # Robert Israel, Aug 03 2025
  • PARI
    a(n)=my(b, c, s); if(n==0,return(0)); b=binary(n); c=length(b); while(!b[c], c=c-1); while(c>0&&b[c], c=c-1); if(c<=0, 0, while(!b[c], c=c-1); s=0; while(c>0&&b[c], c=c-1;s=s+1);s) /* Ralf Stephan, Feb 01 2004 */

Extensions

More terms from Ralf Stephan, Feb 01 2004

A089311 Write n in binary; a(n) = number of 0's in rightmost block of zeros, after dropping any trailing 0's.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Dec 22 2003

Keywords

Examples

			9 = 1001 so a(9) = 2.
		

Crossrefs

Cf. A089309-A089313. Different from A086784.

Programs

  • Mathematica
    bd[n_]:=Module[{s=Split[IntegerDigits[n,2]]},Which[Length[s]<3,0,MemberQ[ Last[s],1],Length[s[[-2]]],True,Length[s[[-3]]]]]; Array[bd,120,0] (* Harvey P. Dale, Dec 29 2013 *)
  • PARI
    a(n)=local(b,c,s):b=binary(n):c=length(b):while(!b[c],c=c-1):while(c>0&&b[c],c=c-1): if(c<=0,0,s=0:while(!b[c],c=c-1:s=s+1):s) \\ Ralf Stephan

Extensions

More terms from Ralf Stephan, Feb 01 2004

A089312 Write n in binary; a(n) = number represented by rightmost block of 1's.

Original entry on oeis.org

0, 1, 1, 3, 1, 1, 3, 7, 1, 1, 1, 3, 3, 1, 7, 15, 1, 1, 1, 3, 1, 1, 3, 7, 3, 1, 1, 3, 7, 1, 15, 31, 1, 1, 1, 3, 1, 1, 3, 7, 1, 1, 1, 3, 3, 1, 7, 15, 3, 1, 1, 3, 1, 1, 3, 7, 7, 1, 1, 3, 15, 1, 31, 63, 1, 1, 1, 3, 1, 1, 3, 7, 1, 1, 1, 3, 3, 1, 7, 15, 1, 1, 1, 3, 1, 1, 3, 7, 3, 1, 1, 3, 7, 1, 15, 31, 3, 1, 1, 3, 1
Offset: 0

Views

Author

N. J. A. Sloane, Dec 22 2003

Keywords

Examples

			13 = 1101 so a(13) = 1.
		

Crossrefs

a(2n+1) = A038712(n+1).

Programs

  • Mathematica
    rb1[n_]:=Module[{id=Split[IntegerDigits[n,2]]},If[MemberQ[ Last[ id],0], FromDigits[ id[[-2]],2], FromDigits[id[[-1]],2]]]; Join[{0}, Array[ rb1,100]] (* Harvey P. Dale, Dec 18 2015 *)

Extensions

More terms from Vladeta Jovovic, Jan 20 2004

A110962 Fractalization of A025480, zero-based version of Kimberling's paraphrases sequence.

Original entry on oeis.org

0, 0, 0, 0, 1, 0, 0, 0, 2, 1, 1, 0, 3, 0, 0, 0, 4, 2, 2, 1, 5, 1, 1, 0, 6, 3, 3, 0, 7, 0, 0, 0, 8, 4, 4, 2, 9, 2, 2, 1, 10, 5, 5, 1, 11, 1, 1, 0, 12, 6, 6, 3, 13, 3, 3, 0, 14, 7, 7, 0, 15, 0, 0, 0, 16, 8, 8, 4, 17, 4, 4, 2, 18, 9, 9, 2, 19, 2, 2, 1, 20, 10, 10, 5, 21, 5, 5, 1, 22, 11, 11, 1, 23, 1, 1, 0, 24, 12, 12
Offset: 0

Views

Author

Alexandre Wajnberg, Sep 26 2005

Keywords

Comments

Self-descriptive sequence: the terms at odd indices are the sequence itself, while the terms at even indices (the skeleton of this sequence) are the terms of A025480, which is a zero-based sequence of Kimberling's paraphrases sequence, A003602.

Crossrefs

One less than A110963 (note also the different starting offsets).

Programs

Formula

For even n, a(n) = A025480(n/2), for odd n, a(n) = a((n-1)/2). - Antti Karttunen, Apr 18 2022
a(2n+1) = a(4n+3) = a(n).
a(2n) = a(4n+1) = a(4n+2) = A025480(n/2).
a(4n) = a(8n+1) = a(8n+2) = n.
a(n) = A110963(1+n) - 1.

Extensions

Entry edited and more terms added by Antti Karttunen, Apr 18 2022

A337821 For n >= 0, a(4n+1) = 0, a(4n+3) = a(2n+1) + 1, a(2n+2) = a(n+1).

Original entry on oeis.org

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

Views

Author

Peter Munn, Sep 23 2020

Keywords

Comments

This sequence is the ruler sequence A007814 interleaved with this sequence; specifically, the odd bisection is A007814, the even bisection is the sequence itself.
The 3-adic valuation of the Doudna sequence (A005940).
The 2-adic valuation of Kimberling's paraphrase (A003602) of the binary number system. [Edited Peter Munn, Aug 13 2025.]

Examples

			Start of table showing the interleaving with ruler sequence, A007814:
   n  a(n)  A007814    a(n/2)
            ((n+1)/2)
   1   0       0
   2   0                 0
   3   1       1
   4   0                 0
   5   0       0
   6   1                 1
   7   2       2
   8   0                 0
   9   0       0
  10   0                 0
  11   1       1
  12   1                 1
  13   0       0
  14   2                 2
  15   3       3
  16   0                 0
  17   0       0
  18   0                 0
  19   1       1
  20   0                 0
  21   0       0
  22   1                 1
  23   2       2
  24   1                 1
		

Crossrefs

Odd bisection: A007814.
A000265, A003602, A005940, A007949 are used in a formula defining this sequence.
Positions of zeros: A091072.
Sequences with similar interleaving: A089309, A014577, A025480, A034947, A038189, A082392, A099545, A181363, A274139.

Programs

  • Mathematica
    a[n_] := IntegerExponent[(n/2^IntegerExponent[n, 2] + 1)/2, 2]; Array[a, 100] (* Amiram Eldar, Sep 30 2020 *)
  • PARI
    a(n) = valuation(n>>valuation(n,2)+1, 2) - 1; \\ Kevin Ryde, Apr 06 2024

Formula

a(2*n) = a(n).
a(2*n+1) = A007814(n+1).
a(n) = A007949(A005940(n)).
a(n) = A007814(A003602(n)) = A007814((A000265(n)+1) / 2) = A089309(n) - 1.
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 1. - Amiram Eldar, Sep 13 2024

A354223 The initial sequence of the positive integers gradually becomes interspersed with the copies of its terms and so is transformed into this sequence. The method is described in the Comments section.

Original entry on oeis.org

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

Views

Author

Tamas Sandor Nagy, May 19 2022

Keywords

Comments

Pre-inked rubberstamps of the positive integers 1, 2, 3, ... are lined up on an infinite paper strip, with sufficient gaps between them. Underneath them already there are their imprints on the paper. We lift and move the first stamp over as many others as is the number of the second one in the line. Then, we press it down on the paper in the gap between the two stamps at that location. We leave it to stand there on its new imprint until its next turn. We successively repeat this with every temporary leading pair: the second stamp will govern the first one, how many others it has to leap over. The ink-printed numbers left uncovered on the paper in front of the receding line of the stamps form the sequence.
It appears that for every new term k > 1, runs of 2^(k-1)-1 length are in this sequence, with k being at the beginning and at the end of these runs. Also, within these runs k repeats itself in the self-same manner, only in reverse order. Could this indicate a fractal property?
If you take the first differences of this sequence as a new sequence and remove all negative numbers from it, then you will obtain A089309. - Thomas Scheuerle, May 20 2022

Examples

			The initial line of the stamps:
(1) (2) (3)         (4)         (5) ...
Stamp (1) leaps over two others as is governed by stamp (2), leaving its imprint 1 in front:
1  (2) (3) (1)     (4)         (5) ...
Stamp (2) leaps over three others as stamp (3) dictates. Its imprint 2 remains on the paper:
1   2  (3) (1)     (4) (2)     (5) ...
Stamp (3) leaps over only the stamp (1), leaving its imprint 3 behind:
1   2   3  (1) (3) (4) (2)     (5) ...
Now stamp (1) leaps again, over three others into the gap between stamps (2) and (5). Its print 1 remains:
1   2   3   1  (3) (4) (2) (1) (5) ...
(And so on.)
		

Crossrefs

Programs

  • MATLAB
    function a = A354223( max_n )
      a = [1:max_n];
      for n = 1:max_n
          m = a(n);
          j = a(n+1);
          a = [a(1:n+j) m a(n+j+1:end)];
      end
      a = a(1:max_n);
    end % Thomas Scheuerle, May 20 2022

Formula

From Thomas Scheuerle, May 19 2022: (Start)
a(2^(m+1) + n - 1) - a(n) < 2, if n < 2^(m+1) - m. This evaluates to zero for all n with m+1 exceptions. For these exceptions it will become 1. The exceptions are n = {A132045(m), A132045(m)+2^m, A132045(m)+2^m+2^(m-1), A132045(m)+2^m+2^(m-1)+2^(m-2), ..., A132045(m)+2^(m+1)-1}.
(1/n)*Sum_{k=1..n} a(k) <= 3. It appears that this arithmetic mean converges to 3 if n approaches infinity.
a(1 + Sum_{k=1..n} A090739(k)) = a(1 + A120738(n - 1)) = 1.
a(Sum_{k=1..n} (1 + A195986(k))) = 2. (End)

A334173 Least i such that i-th term of Thue-Morse sequence (A010060) differs from (i + n)-th term.

Original entry on oeis.org

0, 0, 2, 0, 1, 4, 0, 0, 1, 2, 0, 8, 0, 0, 2, 0, 1, 2, 0, 4, 0, 0, 1, 16, 0, 0, 2, 0, 1, 4, 0, 0, 1, 2, 0, 4, 0, 0, 1, 8, 0, 0, 2, 0, 1, 2, 0, 32, 0, 0, 2, 0, 1, 4, 0, 0, 1, 2, 0, 8, 0, 0, 2, 0, 1, 2, 0, 4, 0, 0, 1, 8, 0, 0, 2, 0, 1, 2, 0, 16, 0, 0, 2, 0, 1, 4
Offset: 1

Views

Author

Jeffrey Shallit, Apr 17 2020

Keywords

Comments

If the Thue-Morse sequence t(n) = A010060(n) = 1 then i=0 suffices since t(0)=0 != t(n). If t(n)=0 then any 1-bits of i in the low 0-bits of n are the same in i and i+n so still t(i) = t(i+n). The next smallest i is the lowest 1-bit of n (A006519). If the lowest run of 1-bits in n is an odd length then adding this i does not change 1's parity (for example binary n = 0111 becomes i+n = 1000) so that t(i+n) = t(n) = 0 != t(i) = 1. If the lowest run of 1-bits in n is an even length then the second lowest 1-bit of n is the next smallest i and similarly does not change 1's parity of i+n. - Kevin Ryde, Apr 27 2020

Examples

			The first few terms of the Thue-Morse sequence are: 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0... . Note that the Thue-Morse sequence has offset 0.
For n = 1, we see that the least i such that i and i + n index different terms is i = 0. Hence a(1) = 0.
For n = 2, the least i such that i and i + n index different terms is also i = 0. Hence a(2) = 0.
For n = 3, i = 0 won't work because Thue-Morse(0) and Thue-Morse(3) are both 0. Nor will i = 1 do because Thue-Morse(1) and Thue-Morse(4) are both 1. With i = 2, we see that Thue-Morse(2) = 1 and Thue-Morse(5) = 0. Hence a(3) = 0.
		

Crossrefs

Cf. A010060 (Thue-Morse), A006519 (lowest 1-bit), A089309 (length of lowest run of 1's).

Programs

  • Mathematica
    Array[Block[{i = 0}, While[ThueMorse[i] == ThueMorse[i + #], i++]; i] &, 86] (* Michael De Vlieger, Jun 27 2020 *)
  • PARI
    a(n)=if(n<3,return(0)); my(k); if(n%2==0, k=valuation(n,2); return(a(n>>k)<>2)); \\ Charles R Greathouse IV, Apr 18 2020
    
  • PARI
    a(n) = if(hammingweight(n)%2,0, my(k=valuation(n,2)); 1 << (k + (valuation((n>>k)+1,2)%2==0))); \\ Kevin Ryde, Apr 27 2020

Formula

a(2*n) = 2*a(n).
a(8*n + 1) = a(4*n + 1) = A010060(n).
a(8*n + 5) = 1 - A010060(n).
a(8*n + 7) = a(2*n + 1).
a(16*n + 3) = a(8*n + 3) = 2 - 2*A010060(n).
a(16*n + 11) = 2*A010060(n).
This system lets you compute a(n) very quickly.
a(n)=0 if A010060(n)=1, otherwise a(n) = A006519(n) or 2*A006519(n) according as A089309(n) odd or even respectively; where A006519 takes the lowest 1-bit of n, and A089309 is the length of the lowest run of 1-bits of n. - Kevin Ryde, Apr 27 2020
Previous Showing 11-17 of 17 results.