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 21-30 of 30 results.

A091090 In binary representation: number of editing steps (delete, insert, or substitute) to transform n into n + 1.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Dec 19 2003

Keywords

Comments

Apparently, one less than the number of cyclotomic factors of the polynomial x^n - 1. - Ralf Stephan, Aug 27 2013
Let the binary expansion of n >= 1 end with m >= 0 1's. Then a(n) = m if n = 2^m-1 and a(n) = m+1 if n > 2^m-1. - Vladimir Shevelev, Aug 14 2017

Crossrefs

This is Guy Steele's sequence GS(2, 4) (see A135416).

Programs

  • Haskell
    a091090 n = a091090_list !! n
    a091090_list = 1 : f [1,1] where f (x:y:xs) = y : f (x:xs ++ [x,x+y])
    -- Same list generator function as for a036987_list, cf. A036987.
    -- Reinhard Zumkeller, Mar 13 2011
    
  • Haskell
    a091090' n = levenshtein (show $ a007088 (n + 1)) (show $ a007088 n) where
      levenshtein :: (Eq t) => [t] -> [t] -> Int
      levenshtein us vs = last $ foldl transform [0..length us] vs where
        transform xs@(x:xs') c = scanl compute (x+1) (zip3 us xs xs') where
          compute z (c', x, y) = minimum [y+1, z+1, x + fromEnum (c' /= c)]
    -- Reinhard Zumkeller, Jun 09 2015
    
  • Haskell
    -- following Vladeta Jovovic's formula
    import Data.List (transpose)
    a091090'' n = vjs !! n where
       vjs = 1 : 1 : concat (transpose [[1, 1 ..], map (+ 1) $ tail vjs])
    -- Reinhard Zumkeller, Jun 09 2015
    
  • Maple
    A091090 := proc(n)
        if n = 0 then
            1;
        else
            A007814(n+1)+1-A036987(n) ;
        end if;
    end proc:
    seq(A091090(n),n=0..100); # R. J. Mathar, Sep 07 2016
    # Alternatively, explaining the connection with A135517:
    a := proc(n) local count, k; count := 1; k := n;
    while k <> 1 and k mod 2 <> 0 do count := count + 1; k := iquo(k, 2) od:
    count end: seq(a(n), n=0..101); # Peter Luschny, Aug 10 2017
  • Mathematica
    a[n_] := a[n] = Which[n==0, 1, n==1, 1, EvenQ[n], 1, True, a[(n-1)/2] + 1]; Array[a, 102, 0] (* Jean-François Alcover, Aug 12 2017 *)
  • PARI
    a(n)=my(m=valuation(n+1,2)); if(n>>m, m+1, max(m, 1)) \\ Charles R Greathouse IV, Aug 15 2017
    
  • Python
    def A091090(n): return (~(n+1)&n).bit_length()+bool(n&(n+1)) if n else 1 # Chai Wah Wu, Sep 18 2024

Formula

a(n) = LevenshteinDistance(A007088(n), A007088(n + 1)).
a(n) = A007814(n + 1) + 1 - A036987(n).
a(n) = A152487(n + 1, n). - Reinhard Zumkeller, Dec 06 2008
a(A004275(n)) = 1. - Reinhard Zumkeller, Mar 13 2011
From Vladeta Jovovic, Aug 25 2004, fixed by Reinhard Zumkeller, Jun 09 2015: (Start)
a(2*n) = 1, a(2*n + 1) = a(n) + 1 for n > 0.
G.f.: 1 + Sum_{k > 0} x^(2^k - 1)/(1 - x^(2^(k - 1))). (End)
Let T(x) be the g.f., then T(x) - x*T(x^2) = x/(1 - x). - Joerg Arndt, May 11 2010
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 2. - Amiram Eldar, Sep 29 2023
a(n) = A000120(n) + A070939(n) - A000120(n+1) - A070939(n+1) + 2. - Chai Wah Wu, Sep 18 2024

A008687 Number of 1's in 2's complement representation of -n.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

a(A127904(n)) = n and a(m) < n for m < A127904(n). - Reinhard Zumkeller, Feb 05 2007
a(n) = A000120(A010078(n)), n>0; a(n) = A023416(A004754(n-1)), n>1. - Reinhard Zumkeller, Dec 04 2015
Conjecture: a(n)+1 is the length of the Hirzebruch (negative) continued fraction for the Stern-Brocot tree fraction A007305(n)/A007306(n). - Andrey Zabolotskiy, Apr 17 2020
Terms a(n); n >= 2 can be generated recursively, as follows. Let S(0) = {1}, then for k >=1, let S(k) = {S(k-1)+1, S(k-1)}, where +1 means +1 on every term of S(k-1); see Example. Each step of the recursion gives the next 2^k terms of the sequence. - David James Sycamore, Jul 15 2024

Examples

			Using the above recursion for a(n); n >= 2, we have:
 S(0) = {1} so a(2) = 1;
 S(1) = {2,1} so a(3,4) = 2,1;
 S(2) = {3,2,2,1}, so a(5,6,7,8) = 3,2,2,1;
As irregular table the sequence for n >= 2 begins:
  1;
  2,1;
  3,2,2,1;
  4,3,3,2,3,2,2,1;
  5,4,4,3,4,3,3,2,4,3,3,2,3,2,2,1;
  6,5,5,4,5,4,4,3,5,4,3,3,4,3,3,2,5,4,4,3,4,3,3,2,4,3,3,2,3,2,2,1;
and so on (the k-th row contains 2^k terms; k>=0). - _David James Sycamore_, Jul 15 2024
		

Crossrefs

This is Guy Steele's sequence GS(4, 3) (see A135416).

Programs

  • Haskell
    a008687 n = a008687_list !! n
    a008687_list = 0 : 1 : c [1] where c (e:es) = e : c (es ++ [e+1,e])
    -- Reinhard Zumkeller, Mar 07 2011
    
  • Mathematica
    a[0] = 0; a[1] = 1; a[n_] := a[n] = Mod[n,2] + a[Mod[n,2] + Floor[n/2]]; Array[a, 96, 0] (* Jean-François Alcover, Aug 12 2017, after Reinhard Zumkeller *)
  • PARI
    a(n) = if(n<2,n, n--; logint(n,2) - hammingweight(n) + 2); \\ Kevin Ryde, Apr 14 2021

Formula

a(n) = A023416(n-1) + 1.
a(n) = if n<=1 then n else (n mod 2) + a((n mod 2) + floor(n/2)). - Reinhard Zumkeller, Feb 05 2007
a(n) = if n<2 then n else a(ceiling(n/2)) + n mod 2. - Reinhard Zumkeller, Jul 25 2006
Min{m: a(m)=n} = if n>0 then A083318(n-1) else 0. - Reinhard Zumkeller, Jul 25 2006

A135528 1, then repeat 1,0.

Original entry on oeis.org

1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0
Offset: 1

Views

Author

N. J. A. Sloane, based on a message from Guy Steele and Don Knuth, Mar 01 2008

Keywords

Comments

This is Guy Steele's sequence GS(2, 1) (see A135416).
2-adic expansion of 1/3 (right to left): 1/3 = ...01010101010101011. - Philippe Deléham, Mar 24 2009
Also, with offset 0, parity of A036467(n-1). - Omar E. Pol, Mar 17 2015
Appears to be the Gilbreath transform of 1,2,3,5,7,11,13,... (A008578). (This is essentially the same as the Gilbreath conjecture, see A036262.) - N. J. A. Sloane, May 08 2023

Examples

			G.f. = x + x^2 + x^4 + x^6 + x^8 + x^10 + x^12 + x^14 + x^16 + x^18 + x^20 + ...
		

Crossrefs

Programs

  • Haskell
    a135528 n = a135528_list !! (n-1)
    a135528_list = concat $ iterate ([1,0] *) [1]
    instance Num a => Num [a] where
    fromInteger k = [fromInteger k]
       (p:ps) + (q:qs) = p + q : ps + qs
       ps + qs         = ps ++ qs
       (0:ps) * qs         = 0 : ps * qs
       (p:ps) * qs'@(q:qs) = p * q : ps * qs' + [p] * qs
        *                = []
    -- Reinhard Zumkeller, Apr 02 2011
  • Maple
    GS(2,1,200); [see A135416].
  • Mathematica
    Prepend[Table[Mod[n + 1, 2], {n, 2, 60}], 1] (* Michael De Vlieger, Mar 17 2015 *)
    PadRight[{1},120,{0,1}] (* Harvey P. Dale, Apr 23 2024 *)

Formula

G.f.: x*(1+x-x^2)/(1-x^2). - Philippe Deléham, Feb 08 2012
G.f.: x / (1 - x / (1 + x / (1 + x / (1 - x)))). - Michael Somos, Apr 02 2012
a(n) = A049711(n+2) mod 2. - Ctibor O. Zizka, Jan 28 2019

A135481 a(n) = 2^A007814(n+1) - 1.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, based on a message from Guy Steele and Don Knuth, Mar 01 2008

Keywords

Comments

This is Guy Steele's sequence GS(1, 6) (see A135416).

Crossrefs

Cf. A006519, A007814, A135416, A140670, A136013 (partial sums).

Programs

Formula

a(n) = A006519(n+1) - 1. - R. J. Mathar, Feb 10 2016

Extensions

a(0) = 0 prepended by Andrey Zabolotskiy, Oct 08 2019, based on Lothar Esser's contribution

A135517 a(n) = 2^(A091090(n)-1).

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, based on a message from Guy Steele and Don Knuth, Mar 01 2008

Keywords

Comments

Also, a(n) = denominator(Euler(n, x) - Euler(n, 1)). - Observation from Peter Luschny, Aug 08 2017, proof from Vladimir Shevelev, Aug 13 2017
Also, a(n) = denominator(Euler(n,x) + Euler(n,0)). - Vladimir Shevelev, Aug 09 2017

Crossrefs

This is Guy Steele's sequence GS(2, 5) (see A135416).
Cf. A091090.

Programs

  • Maple
    GS(2,5,200); # see A135416.
    a := n -> `if`(n=1 or n mod 2 = 0, 1, 2*a(iquo(n,2))):
    seq(a(n), n=0..103); # Peter Luschny, Aug 09 2017
  • Mathematica
    b[n_] := b[n] = Which[n==0, 1, n==1, 1, EvenQ[n], 1, True, b[(n-1)/2] + 1]; a[n_] := 2^(b[n+1]-1); Array[a,103,0] (* Jean-François Alcover, Aug 12 2017 *)
  • PARI
    a(n)=my(m=valuation(n+1,2)); 2^if(n>>m, m, m-1) \\ Charles R Greathouse IV, Aug 15 2017
    
  • Python
    def A135517(n): return (1<<(~(n+1)&n).bit_length()-(not n&(n+1))) if n else 1 # Chai Wah Wu, Sep 18 2024

Formula

For n >= 1, a(n) = 2^max_{odd k=1..n} (A007814(k+1) - t(n,k) - delta(n,k)), where delta(n,k) is the Kronecker symbol: delta(i,j) is 1 if i=j and 0 otherwise, and t(n,k) is the number of carries which appear in the addition of k and n-k in base 2. This allows us to answer in the affirmative the author's question (for a proof see Shevelev's link and its continuations). - Vladimir Shevelev, Aug 15 2017

Extensions

Entry revised by N. J. A. Sloane, Aug 31 2017

A135523 a(n) = A007814(n) + A209229(n).

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, based on a message from Guy Steele and Don Knuth, Mar 01 2008

Keywords

Crossrefs

This is Guy Steele's sequence GS(4, 1) (see A135416).
One less than A135560.

Programs

Formula

G.f.: x + Sum_{k>=1} x^(2^k)*(1 + 1/(1 - x^(2^k))). - Ilya Gutkovskiy, Mar 30 2017
a(n) = A135560(n) - 1. Antti Karttunen, Sep 27 2018

A135534 a(1) = 1; for n>=1, a(2n) = A135561(n), a(2n+1) = 0.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, based on a message from Guy Steele and Don Knuth, Mar 01 2008

Keywords

Crossrefs

Cf. A135416.
This is Guy Steele's sequence GS(6, 1) (see A135416).

Programs

  • Maple
    GS(6,1,200); [see A135416].
  • PARI
    A135560(n) = { my(t=valuation(n, 2)); (t + (n==2^t) + 1); }; \\ From A135560
    A135534(n) = if(1==n,1,if((n%2),0,((2^(A135560(n/2)))-1))); \\ Antti Karttunen, Sep 27 2018
    
  • Python
    def A135534(n): return 1 if n == 1 else 0 if n&1 else (1<<(m:=(~(k:=n>>1) & k-1)).bit_length()+int(m==k-1)+1)-1 # Chai Wah Wu, Jul 06 2022

A182660 a(2^(k+1)) = k; 0 everywhere else.

Original entry on oeis.org

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

Views

Author

Sam Alexander, Nov 27 2010

Keywords

Comments

A surjection N->N designed to spite a guesser who is trying to guess whether it's a surjection, using the following naive guessing method: Guess that (n0,...,nk) is a subsequence of a surjection iff it contains every natural less than log_2(k+1).
This sequence causes the would-be guesser to change his mind infinitely often.
a(0)=0. Assume a(0),...,a(n) have been defined.
If the above guesser guesses that (a(0),...,a(n)) IS the beginning of a surjective sequence, then let a(n+1)=0. Otherwise let a(n+1) be the least number not in (a(0),...,a(n)).

Crossrefs

Programs

  • Magma
    [ exists(t){ k: k in [1..Ceiling(Log(n+1))] | n eq 2^(k+1) } select t else 0: n in [0..100] ];
    
  • PARI
    A182660(n) = if(n<2,0,my(p = 0, k = isprimepower(n,&p)); if(2==p,k-1,0)); \\ Antti Karttunen, Jul 22 2018

A135521 a(n) = 2^(A091090(n)) - 1.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, based on a message from Guy Steele and Don Knuth, Mar 01 2008

Keywords

Examples

			From _Omar E. Pol_, Mar 11 2011: (Start)
Can be written as a triangle with 2^k entries on each row:
1,
1,3,
1,3,1,7,
1,3,1,7,1,3,1,15,
1,3,1,7,1,3,1,15,1,3,1,7,1,3,1,31,
1,3,1,7,1,3,1,15,1,3,1,7,1,3,1,31,1,3,1,7,1,3,1,15,1,3, 1,7,1,3,1,63,
Last term of rows are 2^(k+1) - 1. It appears that the row sums give A001787.
(End)
		

Crossrefs

This is Guy Steele's sequence GS(2, 6) (see A135416).
Cf. A000225, A001787. - Omar E. Pol, Mar 11 2011

Programs

  • Maple
    GS(2,6,200); [see A135416].
    # Input n is the number of rows.
    A135521_list := proc(n) local i,k,NimSum;
    NimSum := proc(a,b) option remember; local i;
    zip((x,y)->`if`(x<>y,1,0),convert(a,base,2),convert(b,base,2),0);
    add(`if`(%[i]=1,2^(i-1),0),i=1..nops(%)) end:
    seq(seq(NimSum(i,i+1),i=0..2^k-1),k=0..n) end:
    A135521_list(5); # Peter Luschny, May 31 2011
  • Mathematica
    Flatten[Table[BitXor[i, i + 1], {k, 0, 10}, {i, 0, -1 + 2^k}]] (* Peter Luschny, May 31 2011 *)
  • PARI
    A091090(n) = { my(m=valuation(n+1, 2)); if(n>>m, m+1, max(m, 1)); }; \\ From A091090
    A135521(n) = ((2^A091090(n))-1); \\ Antti Karttunen, Sep 27 2018

Formula

G.f. A(x) satisfies: A(x) = x/(1 - x) + 2*x*A(x^2). - Ilya Gutkovskiy, Dec 18 2019

A135540 a(n) = 2^(A000523(n) - A000120(n) + 2) - 1.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, based on a message from Guy Steele and Don Knuth, Mar 01 2008

Keywords

Crossrefs

Cf. A135416.
This is Guy Steele's sequence GS(6, 3) (see A135416).

Programs

  • Maple
    GS(6,3,200); [see A135416].
  • Mathematica
    Table[2^(Floor[Log[2, n]] - (n - Sum[Floor[n/2^k], {k, 1, n}]) + 2) - 1, {n,1,25}] (* G. C. Greubel, Oct 18 2016 *)

Formula

a(n) = 2^(floor(log_2(n)) - (n - Sum_{k=1,..,n}[floor(n/2^k)]) + 2) - 1. - G. C. Greubel, Oct 18 2016
Previous Showing 21-30 of 30 results.