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-20 of 350 results. Next

A002487 Stern's diatomic series (or Stern-Brocot sequence): a(0) = 0, a(1) = 1; for n > 0: a(2*n) = a(n), a(2*n+1) = a(n) + a(n+1).

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Also called fusc(n) [Dijkstra].
a(n)/a(n+1) runs through all the reduced nonnegative rationals exactly once [Stern; Calkin and Wilf].
If the terms are written as an array:
column 0 1 2 3 4 5 6 7 8 9 ...
row 0: 0
row 1: 1
row 2: 1,2
row 3: 1,3,2,3
row 4: 1,4,3,5,2,5,3,4
row 5: 1,5,4,7,3,8,5,7,2,7,5,8,3,7,4,5
row 6: 1,6,5,9,4,11,7,10,3,11,8,13,5,12,7,9,2,9,7,12,5,13,8,11,3,10,...
...
then (ignoring row 0) the sum of the k-th row is 3^(k-1), each column is an arithmetic progression and the steps are nothing but the original sequence. - Takashi Tokita (butaneko(AT)fa2.so-net.ne.jp), Mar 08 2003
From N. J. A. Sloane, Oct 15 2017: (Start)
The above observation can be made more precise. Let A(n,k), n >= 0, 0 <= k <= 2^(n-1)-1 for k > 0, denote the entry in row n and column k of the left-justified array above.
The equations for columns 0,1,2,3,4,... are successively (ignoring row 0):
1 (n >= 1),
n (n >= 2),
n-1 (n >= 3),
2n-3 (n >= 3),
n-2 (n >= 4),
3n-7 (n >= 4),
...
and in general column k > 0 is given by
A(n,k) = a(k)*n - A156140(k) for n >= ceiling(log_2(k+1))+1, and 0 otherwise.
(End)
a(n) is the number of odd Stirling numbers S_2(n+1, 2r+1) [Carlitz].
Moshe Newman proved that the fraction a(n+1)/a(n+2) can be generated from the previous fraction a(n)/a(n+1) = x by 1/(2*floor(x) + 1 - x). The successor function f(x) = 1/(floor(x) + 1 - frac(x)) can also be used.
a(n+1) = number of alternating bit sets in n [Finch].
If f(x) = 1/(1 + floor(x) - frac(x)) then f(a(n-1)/a(n)) = a(n)/a(n+1) for n >= 1. If T(x) = -1/x and f(x) = y, then f(T(y)) = T(x) for x > 0. - Michael Somos, Sep 03 2006
a(n+1) is the number of ways of writing n as a sum of powers of 2, each power being used at most twice (the number of hyperbinary representations of n) [Carlitz; Lind].
a(n+1) is the number of partitions of the n-th integer expressible as the sum of distinct even-subscripted Fibonacci numbers (= A054204(n)), into sums of distinct Fibonacci numbers [Bicknell-Johnson, theorem 2.1].
a(n+1) is the number of odd binomial(n-k, k), 0 <= 2*k <= n. [Carlitz], corrected by Alessandro De Luca, Jun 11 2014
a(2^k) = 1. a(3*2^k) = a(2^(k+1) + 2^k) = 2. Sequences of terms between a(2^k) = 1 and a(2^(k+1)) = 1 are palindromes of length 2^k-1 with a(2^k + 2^(k-1)) = 2 in the middle. a(2^(k-1) + 1) = a(2^k - 1) = k+1 for k > 1. - Alexander Adamchuk, Oct 10 2006
The coefficients of the inverse of the g.f. of this sequence form A073469 and are related to binary partitions A000123. - Philippe Flajolet, Sep 06 2008
It appears that the terms of this sequence are the number of odd entries in the diagonals of Pascal's triangle at 45 degrees slope. - Javier Torres (adaycalledzero(AT)hotmail.com), Aug 06 2009
Let M be an infinite lower triangular matrix with (1, 1, 1, 0, 0, 0, ...) in every column shifted down twice:
1;
1, 0;
1, 1, 0;
0, 1, 0, 0;
0, 1, 1, 0, 0;
0, 0, 1, 0, 0, 0;
0, 0, 1, 1, 0, 0, 0;
...
Then this sequence A002487 (without initial 0) is the first column of lim_{n->oo} M^n. (Cf. A026741.) - Gary W. Adamson, Dec 11 2009 [Edited by M. F. Hasler, Feb 12 2017]
Member of the infinite family of sequences of the form a(n) = a(2*n); a(2*n+1) = r*a(n) + a(n+1), r = 1 for A002487 = row 1 in the array of A178239. - Gary W. Adamson, May 23 2010
Equals row 1 in an infinite array shown in A178568, sequences of the form
a(2*n) = r*a(n), a(2*n+1) = a(n) + a(n+1); r = 1. - Gary W. Adamson, May 29 2010
Row sums of A125184, the Stern polynomials. Equivalently, B(n,1), the n-th Stern polynomial evaluated at x = 1. - T. D. Noe, Feb 28 2011
The Kn1y and Kn2y triangle sums, see A180662 for their definitions, of A047999 lead to the sequence given above, e.g., Kn11(n) = A002487(n+1) - A000004(n), Kn12(n) = A002487(n+3) - A000012(n), Kn13(n) = A002487(n+5) - A000034(n+1) and Kn14(n) = A002487(n+7) - A157810(n+1). For the general case of the knight triangle sums see the Stern-Sierpiński triangle A191372. This triangle not only leads to Stern's diatomic series but also to snippets of this sequence and, quite surprisingly, their reverse. - Johannes W. Meijer, Jun 05 2011
Maximum of terms between a(2^k) = 1 and a(2^(k+1)) = 1 is the Fibonacci number F(k+2). - Leonid Bedratyuk, Jul 04 2012
Probably the number of different entries per antidiagonal of A223541. That would mean there are exactly a(n+1) numbers that can be expressed as a nim-product 2^x*2^y with x + y = n. - Tilman Piesk, Mar 27 2013
Let f(m,n) be the frequency of the integer n in the interval [a(2^(m-1)), a(2^m-1)]. Let phi(n) be Euler's totient function (A000010). Conjecture: for all integers m,n n<=m f(m,n) = phi(n). - Yosu Yurramendi, Sep 08 2014
Back in May 1995, it was proved that A000360 is the modulo 3 mapping, (+1,-1,+0)/2, of this sequence A002487 (without initial 0). - M. Jeremie Lafitte (Levitas), Apr 24 2017
Define a sequence chf(n) of Christoffel words over an alphabet {-,+}: chf(1) = '-'; chf(2*n+0) = negate(chf(n)); chf(2*n+1) = negate(concatenate(chf(n),chf(n+1))). Then the length of the chf(n) word is fusc(n) = a(n); the number of '-'-signs in the chf(n) word is c-fusc(n) = A287729(n); the number of '+'-signs in the chf(n) word is s-fusc(n) = A287730(n). See examples below. - I. V. Serov, Jun 01 2017
The sequence can be extended so that a(n) = a(-n), a(2*n) = a(n), a(2*n+1) = a(n) + a(n+1) for all n in Z. - Michael Somos, Jun 25 2019
Named after the German mathematician Moritz Abraham Stern (1807-1894), and sometimes also after the French clockmaker and amateur mathematician Achille Brocot (1817-1878). - Amiram Eldar, Jun 06 2021
It appears that a(n) is equal to the multiplicative inverse of A007305(n+1) mod A007306(n+1). For example, a(12) is 2, the multiplicative inverse of A007305(13) mod A007306(13), where A007305(13) is 4 and A007306(13) is 7. - Gary W. Adamson, Dec 18 2023

Examples

			Stern's diatomic array begins:
  1,1,
  1,2,1,
  1,3,2,3,1,
  1,4,3,5,2,5,3,4,1,
  1,5,4,7,3,8,5,7,2,7,5,8,3,7,4,5,1,
  1,6,5,9,4,11,7,10,3,11,8,13,5,12,7,9,2,9,7,12,5,13,8,11,3,10,7,11,4,9,...
  ...
a(91) = 19, because 91_10 = 1011011_2; b_6=b_4=b_3=b_1=b_0=1, b_5=b_2=0;  L=5; m_1=0, m_2=1, m_3=3, m_4=4, m_5=6; c_1=2, c_2=3, c_3=2, c_4=3; f(1)=1, f(2)=2, f(3)=5, f(4)=8, f(5)=19. - _Yosu Yurramendi_, Jul 13 2016
From _I. V. Serov_, Jun 01 2017: (Start)
a(n) is the length of the Christoffel word chf(n):
n  chf(n) A070939(n)   a(n)
1   '-'       1          1
2   '+'       2          1
3   '+-'      2          2
4   '-'       3          1
5   '--+'     3          3
6   '-+'      3          2
... (End)
G.f. = x + x^2 + 2*x^3 + x^4 + 3*x^5 + 2*x^6 + 3*x^7 + x^8 + ... - _Michael Somos_, Jun 25 2019
		

References

  • M. Aigner and G. M. Ziegler, Proofs from THE BOOK, 3rd ed., Berlin, Heidelberg, New York: Springer-Verlag, 2004, p. 97.
  • Elwyn R. Berlekamp, John H. Conway and Richard K. Guy, Winning Ways, Academic Press, NY, 2 vols., 1982, see p. 114.
  • Krishna Dasaratha, Laure Flapan, Chansoo Lee, Cornelia Mihaila, Nicholas Neumann-Chun, Sarah Peluse and Matthew Stroegeny, A family of multi-dimensional continued fraction Stern sequences, Abtracts Amer. Math. Soc., Vol. 33 (#1, 2012), #1077-05-2543.
  • Edsger W. Dijkstra, Selected Writings on Computing, Springer, 1982, p. 232 (sequence is called fusc).
  • F. G. M. Eisenstein, Eine neue Gattung zahlentheoretischer Funktionen, welche von zwei Elementen abhaengen und durch gewisse lineare Funktional-Gleichungen definirt werden, Verhandlungen der Koenigl. Preuss. Akademie der Wiss. Berlin (1850), pp. 36-42, Feb 18, 1850. Werke, II, pp. 705-711.
  • Graham Everest, Alf van der Poorten, Igor Shparlinski and Thomas Ward, Recurrence Sequences, Amer. Math. Soc., 2003; see esp. p. 255.
  • Steven R. Finch, Mathematical Constants, Cambridge, 2003, Section 2.16.3; pp. 148-149.
  • Ronald L. Graham, Donald E. Knuth and Oren Patashnik, Concrete Mathematics. Addison-Wesley, Reading, MA, 1990, p. 117.
  • Thomas Koshy, Fibonacci and Lucas numbers with applications, Wiley, 2001, p. 98.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Record values are in A212289.
If the 1's are replaced by pairs of 1's we obtain A049456.
Inverse: A020946.
Cf. a(A001045(n)) = A000045(n). a(A062092(n)) = A000032(n+1).
Cf. A064881-A064886 (Stern-Brocot subtrees).
A column of A072170.
Cf. A049455 for the 0,1 version of Stern's diatomic array.
Cf. A000119, A262097 for analogous sequences in other bases and A277189, A277315, A277328 for related sequences with similar graphs.
Cf. A086592 and references therein to other sequences related to Kepler's tree of fractions.

Programs

  • Haskell
    a002487 n = a002487_list !! n
    a002487_list = 0 : 1 : stern [1] where
       stern fuscs = fuscs' ++ stern fuscs' where
         fuscs' = interleave fuscs $ zipWith (+) fuscs $ (tail fuscs) ++ [1]
       interleave []     ys = ys
       interleave (x:xs) ys = x : interleave ys xs
    -- Reinhard Zumkeller, Aug 23 2011
    
  • Julia
    using Nemo
    function A002487List(len)
        a, A = QQ(0), [0,1]
        for n in 1:len
            a = next_calkin_wilf(a)
            push!(A, denominator(a))
        end
    A end
    A002487List(91) |> println # Peter Luschny, Mar 13 2018
    
  • Magma
    [&+[(Binomial(k, n-k-1) mod 2): k in [0..n]]: n in [0..100]]; // Vincenzo Librandi, Jun 18 2019
    
  • Maple
    A002487 := proc(n) option remember; if n <= 1 then n elif n mod 2 = 0 then procname(n/2); else procname((n-1)/2)+procname((n+1)/2); fi; end: seq(A002487(n),n=0..91);
    A002487 := proc(m) local a,b,n; a := 1; b := 0; n := m; while n>0 do if type(n,odd) then b := a+b else a := a+b end if; n := floor(n/2); end do; b; end proc: seq(A002487(n),n=0..91); # Program adapted from E. Dijkstra, Selected Writings on Computing, Springer, 1982, p. 232. - Igor Urbiha (urbiha(AT)math.hr), Oct 28 2002. Since A007306(n) = a(2*n+1), this program can be adapted for A007306 by replacing b := 0 by b := 1.
    A002487 := proc(n::integer) local k; option remember; if n = 0 then 0 elif n=1 then 1 else add(K(k,n-1-k)*procname(n - k), k = 1 .. n) end if end proc:
    K := proc(n::integer, k::integer) local KC; if 0 <= k and k <= n and n-k <= 2 then KC:=1; else KC:= 0; end if; end proc: seq(A002487(n),n=0..91); # Thomas Wieder, Jan 13 2008
    # next Maple program:
    a:= proc(n) option remember; `if`(n<2, n,
          (q-> a(q)+(n-2*q)*a(n-q))(iquo(n, 2)))
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Feb 11 2021
    fusc := proc(n) local a, b, c; a := 1; b := 0;
        for c in convert(n, base, 2) do
            if c = 0 then a := a + b else b := a + b fi od;
        b end:
    seq(fusc(n), n = 0..91); # Peter Luschny, Nov 09 2022
    Stern := proc(n, u) local k, j, b;
        b := j -> nops({seq(Bits:-Xor(k, j-k), k = 0..j)}):
        ifelse(n=0, 1-u, seq(b(j), j = 2^(n-1)-1..2^n-1-u)) end:
    seq(print([n], Stern(n, 1)), n = 0..5); # As shown in the comments.
    seq(print([n], Stern(n, 0)), n = 0..5); # As shown in the examples. # Peter Luschny, Sep 29 2024
  • Mathematica
    a[0] = 0; a[1] = 1; a[n_] := If[ EvenQ[n], a[n/2], a[(n-1)/2] + a[(n+1)/2]]; Table[ a[n], {n, 0, 100}] (* end of program *)
    Onemore[l_] := Transpose[{l, l + RotateLeft[l]}] // Flatten;
    NestList[Onemore, {1}, 5] // Flatten  (*gives [a(1), ...]*) (* Takashi Tokita, Mar 09 2003 *)
    ToBi[l_] := Table[2^(n - 1), {n, Length[l]}].Reverse[l]; Map[Length,
    Split[Sort[Map[ToBi, Table[IntegerDigits[n - 1, 3], {n, 500}]]]]]  (*give [a(1), ...]*) (* Takashi Tokita, Mar 10 2003 *)
    A002487[m_] := Module[{a = 1, b = 0, n = m}, While[n > 0, If[OddQ[n], b = a+b, a = a+b]; n = Floor[n/2]]; b]; Table[A002487[n], {n, 0, 100}] (* Jean-François Alcover, Sep 06 2013, translated from 2nd Maple program *)
    a[0] = 0; a[1] = 1;
    Flatten[Table[{a[2*n] = a[n], a[2*n + 1] = a[n] + a[n + 1]}, {n, 0, 50}]] (* Horst H. Manninger, Jun 09 2021 *)
    nmax = 100; CoefficientList[Series[x*Product[(1 + x^(2^k) + x^(2^(k+1))), {k, 0, Floor[Log[2, nmax]] + 1}], {x, 0, nmax}], x] (* Vaclav Kotesovec, Oct 08 2022 *)
  • PARI
    {a(n) = n=abs(n); if( n<2, n>0, a(n\2) + if( n%2, a(n\2 + 1)))};
    
  • PARI
    fusc(n)=local(a=1,b=0);while(n>0,if(bitand(n,1),b+=a,a+=b);n>>=1);b \\ Charles R Greathouse IV, Oct 05 2008
    
  • PARI
    A002487(n,a=1,b=0)=for(i=0,logint(n,2),if(bittest(n,i),b+=a,a+=b));b \\ M. F. Hasler, Feb 12 2017, updated Feb 14 2019
    
  • Python
    from functools import lru_cache
    @lru_cache(maxsize=None)
    def a(n): return n if n<2 else a(n//2) if n%2==0 else a((n - 1)//2) + a((n + 1)//2) # Indranil Ghosh, Jun 08 2017; corrected by Reza K Ghazi, Dec 27 2021
    
  • Python
    def a(n):
        a, b = 1, 0
        while n > 0:
            if n & 1:
                b += a
            else:
                a += b
            n >>= 1
        return b
    # Reza K Ghazi, Dec 29 2021
    
  • Python
    def A002487(n): return sum(int(not (n-k-1) & ~k) for k in range(n)) # Chai Wah Wu, Jun 19 2022
    
  • Python
    # (fast way for big vectors)
    from math import log, ceil
    import numpy
    how_many_terms = 2**20  # (Powers of 2 recommended but other integers are also possible.)
    A002487, A002487[1]  = numpy.zeros(2**(ce:=ceil(log(how_many_terms,2))), dtype=object), 1
    for exponent in range(1,ce):
        L, L2 = 2**exponent, 2**(exponent+1)
        A002487[L2 - 1] = exponent + 1
        A002487[L:L2][::2] = A002487[L >> 1: L]
        A002487[L + 1:L2 - 2][::2] = A002487[L:L2 - 3][::2]  +  A002487[L + 2:L2 - 1][::2]
    print(list(A002487[0:100])) # Karl-Heinz Hofmann, Jul 22 2025
  • R
    N <- 50 # arbitrary
    a <- 1
    for (n in 1:N)
    {
      a[2*n    ] = a[n]
      a[2*n + 1] = a[n] + a[n+1]
      a
    }
    a
    # Yosu Yurramendi, Oct 04 2014
    
  • R
    # Given n, compute a(n) by taking into account the binary representation of n
    a <- function(n){
      b <- as.numeric(intToBits(n))
      l <- sum(b)
      m <- which(b == 1)-1
      d <- 1
      if(l > 1) for(j in 1:(l-1)) d[j] <- m[j+1]-m[j]+1
      f <- c(0,1)
      if(l > 1) for(j in 3:(l+1)) f[j] <- d[j-2]*f[j-1]-f[j-2]
      return(f[l+1])
    } # Yosu Yurramendi, Dec 13 2016
    
  • R
    # computes the sequence as a vector A, rather than function a() as above.
    A <- c(1,1)
    maxlevel <- 5 # by choice
    for(m in 1:maxlevel) {
      A[2^(m+1)] <- 1
      for(k in 1:(2^m-1)) {
        r <- m - floor(log2(k)) - 1
        A[2^r*(2*k+1)] <- A[2^r*(2*k)] + A[2^r*(2*k+2)]
    }}
    A # Yosu Yurramendi, May 08 2018
    
  • Sage
    def A002487(n):
        M = [1, 0]
        for b in n.bits():
            M[b] = M[0] + M[1]
        return M[1]
    print([A002487(n) for n in (0..91)])
    # For a dual see A174980. Peter Luschny, Nov 28 2017
    
  • Scheme
    ;; An implementation of memoization-macro definec can be found for example in: http://oeis.org/wiki/Memoization
    (definec (A002487 n) (cond ((<= n 1) n) ((even? n) (A002487 (/ n 2))) (else (+ (A002487 (/ (- n 1) 2)) (A002487 (/ (+ n 1) 2))))))
    ;; Antti Karttunen, Nov 05 2016
    

Formula

a(n+1) = (2*k+1)*a(n) - a(n-1) where k = floor(a(n-1)/a(n)). - David S. Newman, Mar 04 2001
Let e(n) = A007814(n) = exponent of highest power of 2 dividing n. Then a(n+1) = (2k+1)*a(n)-a(n-1), n > 0, where k = e(n). Moreover, floor(a(n-1)/a(n)) = e(n), in agreement with D. Newman's formula. - Dragutin Svrtan (dsvrtan(AT)math.hr) and Igor Urbiha (urbiha(AT)math.hr), Jan 10 2002
Calkin and Wilf showed 0.9588 <= limsup a(n)/n^(log(phi)/log(2)) <= 1.1709 where phi is the golden mean. Does this supremum limit = 1? - Benoit Cloitre, Jan 18 2004. Coons and Tyler show the limit is A246765 = 0.9588... - Kevin Ryde, Jan 09 2021
a(n) = Sum_{k=0..floor((n-1)/2)} (binomial(n-k-1, k) mod 2). - Paul Barry, Sep 13 2004
a(n) = Sum_{k=0..n-1} (binomial(k, n-k-1) mod 2). - Paul Barry, Mar 26 2005
G.f. A(x) satisfies 0 = f(A(x), A(x^2), A(x^4)) where f(u, v, w) = v^3 + 2*u*v*w - u^2*w. - Michael Somos, May 02 2005
G.f. A(x) satisfies 0 = f(A(x), A(x^2), A(x^3), A(x^6)) where f(u1, u2, u3, u6) = u1^3*u6 - 3*u1^2*u2*u6 + 3*u2^3*u6 - u2^3*u3. - Michael Somos, May 02 2005
G.f.: x * Product_{k>=0} (1 + x^(2^k) + x^(2^(k+1))) [Carlitz].
a(n) = a(n-2) + a(n-1) - 2*(a(n-2) mod a(n-1)). - Mike Stay, Nov 06 2006
A079978(n) = (1 + e^(i*Pi*A002487(n)))/2, i=sqrt(-1). - Paul Barry, Jan 14 2005
a(n) = Sum_{k=1..n} K(k, n-k)*a(n - k), where K(n,k) = 1 if 0 <= k AND k <= n AND n-k <= 2 and K(n,k) = 0 else. (When using such a K-coefficient, several different arguments to K or several different definitions of K may lead to the same integer sequence. For example, if we drop the condition k <= n in the above definition, then we arrive at A002083 = Narayana-Zidek-Capell numbers.) - Thomas Wieder, Jan 13 2008
a(k+1)*a(2^n - k) - a(k)*a(2^n - (k+1)) = 1; a(2^n - k) + a(k) = a(2^(n+1) + k). Both formulas hold for 0 <= k <= 2^n - 1. G.f.: G(z) = a(1) + a(2)*z + a(3)*z^2 + ... + a(k+1)*z^k + ... Define f(z) = (1 + z + z^2), then G(z) = lim f(z)*f(z^2)*f(z^4)* ... *f(z^(2^n))*... = (1 + z + z^2)*G(z^2). - Arie Werksma (werksma(AT)tiscali.nl), Apr 11 2008
a(k+1)*a(2^n - k) - a(k)*a(2^n - (k+1)) = 1 (0 <= k <= 2^n - 1). - Arie Werksma (werksma(AT)tiscali.nl), Apr 18 2008
a(2^n + k) = a(2^n - k) + a(k) (0 <= k <= 2^n). - Arie Werksma (werksma(AT)tiscali.nl), Apr 18 2008
Let g(z) = a(1) + a(2)*z + a(3)*z^2 + ... + a(k+1)*z^k + ..., f(z) = 1 + z + z^2. Then g(z) = lim_{n->infinity} f(z)*f(z^2)*f(z^4)*...*f(z^(2^n)), g(z) = f(z)*g(z^2). - Arie Werksma (werksma(AT)tiscali.nl), Apr 18 2008
For 0 <= k <= 2^n - 1, write k = b(0) + 2*b(1) + 4*b(2) + ... + 2^(n-1)*b(n-1) where b(0), b(1), etc. are 0 or 1. Define a 2 X 2 matrix X(m) with entries x(1,1) = x(2,2) = 1, x(1,2) = 1 - b(m), x(2,1) = b(m). Let P(n)= X(0)*X(1)* ... *X(n-1). The entries of the matrix P are members of the sequence: p(1,1) = a(k+1), p(1,2) = a(2^n - (k+1)), p(2,1) = a(k), p(2,2) = a(2^n - k). - Arie Werksma (werksma(AT)tiscali.nl), Apr 20 2008
Let f(x) = A030101(x); if 2^n + 1 <= x <= 2^(n + 1) and y = 2^(n + 1) - f(x - 1) then a(x) = a(y). - Arie Werksma (Werksma(AT)Tiscali.nl), Jul 11 2008
a(n) = A126606(n + 1) / 2. - Reikku Kulon, Oct 05 2008
Equals infinite convolution product of [1,1,1,0,0,0,0,0,0] aerated A000079 - 1 times, i.e., [1,1,1,0,0,0,0,0,0] * [1,0,1,0,1,0,0,0,0] * [1,0,0,0,1,0,0,0,1]. - Mats Granvik and Gary W. Adamson, Oct 02 2009; corrected by Mats Granvik, Oct 10 2009
a(2^(p+2)*n+2^(p+1)-1) - a(2^(p+1)*n+2^p-1) = A007306(n+1), p >= 0 and n >= 0. - Johannes W. Meijer, Feb 07 2013
a(2*n-1) = A007306(n), n > 0. - Yosu Yurramendi, Jun 23 2014
a(n*2^m) = a(n), m>0, n > 0. - Yosu Yurramendi, Jul 03 2014
a(k+1)*a(2^m+k) - a(k)*a(2^m+(k+1)) = 1 for m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Nov 07 2014
a(2^(m+1)+(k+1))*a(2^m+k) - a(2^(m+1)+k)*a(2^m+(k+1)) = 1 for m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Nov 07 2014
a(5*2^k) = 3. a(7*2^k) = 3. a(9*2^k) = 4. a(11*2^k) = 5. a(13*2^k) = 5. a(15*2^k) = 4. In general: a((2j-1)*2^k) = A007306(j), j > 0, k >= 0 (see Adamchuk's comment). - Yosu Yurramendi, Mar 05 2016
a(2^m+2^m'+k') = a(2^m'+k')*(m-m'+1) - a(k'), m >= 0, m' <= m-1, 0 <= k' < 2^m'. - Yosu Yurramendi, Jul 13 2016
From Yosu Yurramendi, Jul 13 2016: (Start)
Let n be a natural number and [b_m b_(m-1) ... b_1 b_0] its binary expansion with b_m=1.
Let L = Sum_{i=0..m} b_i be the number of binary digits equal to 1 (L >= 1).
Let {m_j: j=1..L} be the set of subindices such that b_m_j = 1, j=1..L, and 0 <= m_1 <= m_2 <= ... <= m_L = m.
If L = 1 then c_1 = 1, otherwise let {c_j: j=1..(L-1)} be the set of coefficients such that c_(j) = m_(j+1) - m_j + 1, 1 <= j <= L-1.
Let f be a function defined on {1..L+1} such that f(1) = 0, f(2) = 1, f(j) = c_(j-2)*f(j-1) - f(j-2), 3 <= j <= L+1.
Then a(n) = f(L+1) (see example). (End)
a(n) = A001222(A260443(n)) = A000120(A277020(n)). Also a(n) = A000120(A101624(n-1)) for n >= 1. - Antti Karttunen, Nov 05 2016
(a(n-1) + a(n+1))/a(n) = A037227(n) for n >= 1. - Peter Bala, Feb 07 2017
a(0) = 0; a(3n) = 2*A000360(3n-1); a(3n+1) = 2*A000360(3n) - 1; a(3n+2) = 2*A000360(3n+1) + 1. - M. Jeremie Lafitte (Levitas), Apr 24 2017
From I. V. Serov, Jun 14 2017: (Start)
a(n) = A287896(n-1) - 1*A288002(n-1) for n > 1;
a(n) = A007306(n-1) - 2*A288002(n-1) for n > 1. (End)
From Yosu Yurramendi, Feb 14 2018: (Start)
a(2^(m+2) + 2^(m+1) + k) - a(2^(m+1) + 2^m + k) = 2*a(k), m >= 0, 0 <= k < 2^m.
a(2^(m+2) + 2^(m+1) + k) - a(2^(m+1) + k) = a(2^m + k), m >= 0, 0 <= k < 2^m.
a(2^m + k) = a(k)*(m - floor(log_2(k)) - 1) + a(2^(floor(log_2(k))+1) + k), m >= 0, 0 < k < 2^m, a(2^m) = 1, a(0) = 0. (End)
From Yosu Yurramendi, May 08 2018: (Start)
a(2^m) = 1, m >= 0.
a(2^r*(2*k+1)) = a(2^r*(2*k)) + a(2^r*(2*k+2)), r < - m - floor(log_2(k)) - 1, m > 0, 1 <= k < 2^m. (End)
Trow(n) = [card({k XOR (j-k): k=0..j}) for j = 2^(n-1)-1..2^n-2] when regarded as an irregular table (n >= 1). - Peter Luschny, Sep 29 2024
a(n) = A000120(A168081(n)). - Karl-Heinz Hofmann, Jun 16 2025

Extensions

Additional references and comments from Len Smiley, Joshua Zucker, Rick L. Shepherd and Herbert S. Wilf
Typo in definition corrected by Reinhard Zumkeller, Aug 23 2011
Incorrect formula deleted and text edited by Johannes W. Meijer, Feb 07 2013

A237591 Irregular triangle read by rows: T(n,k) is the difference between the total number of partitions of all positive integers <= n into exactly k consecutive parts, and the total number of partitions of all positive integers <= n into exactly k+1 consecutive parts (n>=1, 1<=k<=A003056(n)).

Original entry on oeis.org

1, 2, 2, 1, 3, 1, 3, 2, 4, 1, 1, 4, 2, 1, 5, 2, 1, 5, 2, 2, 6, 2, 1, 1, 6, 3, 1, 1, 7, 2, 2, 1, 7, 3, 2, 1, 8, 3, 1, 2, 8, 3, 2, 1, 1, 9, 3, 2, 1, 1, 9, 4, 2, 1, 1, 10, 3, 2, 2, 1, 10, 4, 2, 2, 1, 11, 4, 2, 1, 2, 11, 4, 3, 1, 1, 1, 12, 4, 2, 2, 1, 1, 12, 5, 2, 2, 1, 1, 13, 4, 3, 2, 1, 1, 13, 5, 3, 1, 2, 1, 14, 5, 2, 2, 2, 1
Offset: 1

Views

Author

Omar E. Pol, Feb 22 2014

Keywords

Comments

The original name was: Triangle read by rows: T(n,k) = A235791(n,k) - A235791(n,k+1), assuming that the virtual right border of triangle A235791 is A000004.
T(n,k) is also the length of the k-th segment in a zig-zag path on the first quadrant of the square grid, connecting the point (n, 0) with the point (m, m), starting with a segment in vertical direction, where m <= n.
Conjecture: the area of the polygon defined by the x-axis, this zig-zag path and the diagonal [(0, 0), (m, m)], is equal to A024916(n)/2, one half of the sum of all divisors of all positive integers <= n. Therefore the reflected polygon, which is adjacent to the y-axis, with the zig-zag path connecting the point (0, n) with the point (m, m), has the same property. And so on for each octant in the four quadrants.
For the representation of A024916 and A000203 we use two octants, for example: the first octant and the second octant, or the 6th octant and the 7th octant, etc., see A237593.
At least up to n = 128, two zig-zag paths never cross (checked by hand).
The finite sequence formed by the n-th row of triangle together with its mirror row gives the n-th row of triangle A237593.
The connection between A196020 and A237271 is as follows: A196020 --> A236104 --> A235791 --> this sequence --> A237593 --> A239660 --> A237270 --> A237271.
Comments from Franklin T. Adams-Watters on sequences related to the "symmetric representation of sigma" in A235791 and related sequences, Mar 31 2014. (Start)
The place to start is with A235791, which is very simple. Then go to A237591, also very simple, and A237593, still very simple.
You then need to interpret the rows of A237593 as Dyck paths. This interpretation is in terms of run lengths, so 2,1,1,2 means up twice, down once, up once, and down twice. Because the rows of A237593 are symmetric and of even length, this path will always be symmetric.
Now the surprising fact is that the areas enclosed by the Dyck path for n (laid on its side) always includes the area enclosed for n-1; and the number of squares added is sigma(n).
Finally, look at the connected areas enclosed by n but not by n-1; the size of these areas is the symmetric representation of sigma. (End)
From Hartmut F. W. Hoft, Apr 07 2014: (Start)
The row sum is A235791(n,1) - A235791(n,floor((sqrt(8n+1)-1)/2)+1) = n - 0.
Mathematica function has been written to check the conjecture as well as non-crossing zig-zag paths (Dyck paths rotated by 90 degrees) up through n=30000 (same applies to A237593). (End)
The n-th zig-zag path ending at the point (m, m), where m = A240542(n). - Omar E. Pol, Apr 16 2014
From Omar E. Pol, Aug 23 2015: (Start)
n is an odd prime if and only if T(n,2) = 1 + T(n-1,2) and T(n,k) = T(n-1,k) for the rest of the values of k.
The elements of the n-th row of triangle together with the elements of the n-th row of triangle A261350 give the n-th row of triangle A237593.
T(n,k) is also the area (or the number of cells) of the k-th vertical side at the n-th level (starting from the top) in the left hand part of the front view of the stepped pyramid described in A245092, see Example section.
(End)
From Omar E. Pol, Nov 19 2015: (Start)
T(n,k) is also the number of cells between the k-th and the (k+1)st line segments (from left to right) in the n-th row of the diagram as shown in Example section.
Note that the number of horizontal line segments in the n-th row of the diagram equals A001227(n), the number of odd divisors of n. (End)
Conjecture: the values f(n,k) in the n-th row of the triangle are either 1 or 2 for all k with ceiling((sqrt(4*n+1)-1)/2) <= k <= floor((sqrt(8*n+1)-1)/2) = r(n), the length of the n-th row, though the lower bound need not be minimal; tested through 2500000. See also A285356. - Hartmut F. W. Hoft, Apr 17 2017
Conjecture: T(n,k) is the difference between the total number of partitions of all positive integers <= n into exactly k consecutive parts, and the total number of partitions of all positive integers <= n into exactly k+1 consecutive parts. - Omar E. Pol, Apr 30 2017
From Omar E. Pol, Aug 31 2021: (Start)
It appears that T(n,2)/T(n,1) converges to 1/3.
It appears that T(n,3)/T(n,2) converges to 1/2.
It appears that T(n,4)/T(n,3) converges to 3/5.
It appears that T(n,5)/T(n,4) converges to 2/3. (End)
In other words: T(n,k) is the length of the k-th line segment of the largest Dyck path of the symmetric representation of sigma(n). - Omar E. Pol, Sep 08 2021

Examples

			Triangle begins:
   1;
   2;
   2, 1;
   3, 1;
   3, 2;
   4, 1, 1;
   4, 2, 1;
   5, 2, 1;
   5, 2, 2;
   6, 2, 1, 1;
   6, 3, 1, 1;
   7, 2, 2, 1;
   7, 3, 2, 1;
   8, 3, 1, 2;
   8, 3, 2, 1, 1;
   9, 3, 2, 1, 1;
   9, 4, 2, 1, 1;
  10, 3, 2, 2, 1;
  10, 4, 2, 2, 1;
  11, 4, 2, 1, 2;
  11, 4, 3, 1, 1, 1;
  12, 4, 2, 2, 1, 1;
  12, 5, 2, 2, 1, 1;
  13, 4, 3, 2, 1, 1;
  13, 5, 3, 1, 2, 1;
  14, 5, 2, 2, 2, 1;
  14, 5, 3, 2, 1, 2;
  15, 5, 3, 2, 1, 1, 1;
  ...
For n = 10 the 10th row of triangle A235791 is [10, 4, 2, 1] so row 10 is [6, 2, 1, 1].
From _Omar E. Pol_, Aug 23 2015: (Start)
Illustration of initial terms:
  Row                                                         _
   1                                                        _|1|
   2                                                      _|2 _|
   3                                                    _|2  |1|
   4                                                  _|3   _|1|
   5                                                _|3    |2 _|
   6                                              _|4     _|1|1|
   7                                            _|4      |2  |1|
   8                                          _|5       _|2 _|1|
   9                                        _|5        |2  |2 _|
  10                                      _|6         _|2  |1|1|
  11                                    _|6          |3   _|1|1|
  12                                  _|7           _|2  |2  |1|
  13                                _|7            |3    |2 _|1|
  14                              _|8             _|3   _|1|2 _|
  15                            _|8              |3    |2  |1|1|
  16                          _|9               _|3    |2  |1|1|
  17                        _|9                |4     _|2 _|1|1|
  18                      _|10                _|3    |2  |2  |1|
  19                    _|10                 |4      |2  |2 _|1|
  20                  _|11                  _|4     _|2  |1|2 _|
  21                _|11                   |4      |3   _|1|1|1|
  22              _|12                    _|4      |2  |2  |1|1|
  23            _|12                     |5       _|2  |2  |1|1|
  24          _|13                      _|4      |3    |2 _|1|1|
  25        _|13                       |5        |3   _|1|2  |1|
  26      _|14                        _|5       _|2  |2  |2 _|1|
  27    _|14                         |5        |3    |2  |1|2 _|
  28   |15                           |5        |3    |2  |1|1|1|
  ...
Also the diagram represents the left part of the front view of the pyramid described in A245092. For the other half front view see A261350. For more information about the pyramid and the symmetric representation of sigma see A237593. (End)
From _Omar E. Pol_, Sep 08 2021: (Start)
For n = 12 the symmetric representation of sigma(12) in the fourth quadrant is as shown below:
.                           _
                           | |
                           | |
                           | |
                           | |
                           | |
                      _ _ _| |
                    _|    _ _|
                  _|     |
                 |      _|
                 |  _ _|1
      _ _ _ _ _ _| |  2
     |_ _ _ _ _ _ _|2
            7
.
The lengths of the successive line segments from the first vertex to the central vertex of the largest Dyck path are [7, 2, 2, 1] respectively, the same as the 12th row of triangle. (End)
		

Crossrefs

Row n has length A003056(n) hence column k starts in row A000217(k).
Row sums give A000027.
Column 1 is A008619, n >= 1.
Right border gives A042974.

Programs

  • Mathematica
    row[n_]:= Floor[(Sqrt[8*n+1] -1)/2];  f[n_,k_]:= Ceiling[(n+1)/k-(k+1)/2] - Ceiling[(n+1)/(k+1)-(k+2)/2];
    Table[f[n,k],{n,1,50},{k,1,row[n]}]//Flatten
    (* Hartmut F. W. Hoft, Apr 08 2014 *)
  • PARI
    row235791(n) = vector((sqrtint(8*n+1)-1)\2, i, 1+(n-(i*(i+1)/2))\i);
    row(n) = {my(orow = concat(row235791(n), 0)); vector(#orow -1, i, orow[i] - orow[i+1]);} \\ Michel Marcus, Mar 27 2014
    
  • Python
    from sympy import sqrt
    import math
    def T(n, k): return int(math.ceil((n + 1)/k - (k + 1)/2)) - int(math.ceil((n + 1)/(k + 1) - (k + 2)/2))
    for n in range(1, 29): print([T(n, k) for k in range(1, int((sqrt(8*n + 1) - 1)/2) + 1)]) # Indranil Ghosh, Apr 30 2017

Formula

T(n,k) = ceiling((n+1)/k - (k+1)/2) - ceiling((n+1)/(k+1) - (k+2)/2), for 1 <= n and 1 <= k <= floor((sqrt(8n+1)-1)/2). - Hartmut F. W. Hoft, Apr 07 2014

Extensions

3 more rows added by Omar E. Pol, Aug 23 2015
New name from a comment dated Apr 30 2017. - Omar E. Pol, Jun 18 2023

A057427 a(n) = 1 if n > 0, a(n) = 0 if n = 0; series expansion of x/(1-x).

Original entry on oeis.org

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

Views

Author

Henry Bottomley, Sep 05 2000

Keywords

Comments

Parity of (n+1)-st prime, A000040(n+1). - Philippe Deléham, Apr 04 2009
Decimal expansion of 1/90.
Partial sums of A063524 (characteristic function of 1). - Jeremy Gardiner, Sep 08 2002
Characteristic function of positive integers. - Franklin T. Adams-Watters, Aug 01 2011
Number of binary bracelets of n beads, 0 of them 0. Number of binary bracelets of n beads, 1 of them 0. Number of binary bracelets of n beads, 0 of them 0, with 00 prohibited. For n>=2, a(n-1) is the number of binary bracelets of n beads, one of them 0, with 00 prohibited. - Washington Bomfim, Aug 27 2008
Central terms of the triangle in A152487. - Reinhard Zumkeller, Dec 06 2008
This is sgn(n) (or sign(n), or signum(n)) restricted to nonnegative integers. See sequence A261012 for a version that extends the sequence backwards to offset -1.

Examples

			1/90 = .0111111111111111111...
G.f. = x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10 + x^11 + ...
		

References

  • T. M. MacRobert, Functions of a Complex Variable, 4th ed., Macmillan and Co., London, 1958, p. 90.

Crossrefs

Programs

Formula

G.f.: x / (1 - x).
G.f.: Sum_{k>=0} 2^k * x^(2^k) / (1 + x^(2^k)). - Michael Somos, Sep 11 2005
a(A000027(n)) = 1; a(A000004(n)) = 0. - Reinhard Zumkeller, Oct 11 2008
a(n) = A000007(0^n). - Jaume Oliver Lafont, Mar 19 2009
From Michael Somos, Aug 17 2015: (Start)
a(n) = -a(-n) for all n in Z if a(n) is treated as sgn(n).
Sum_{k<0} a(k) * x^k = 1 / (1 - x) if abs(x) > 1. (End)
Dirichlet g.f.: zeta(s) - 1. - Álvar Ibeas, Nov 29 2015; corrected by Francois Oger, Oct 26 2019
a(n) = A001065(n+1) - A048050(n+1). - Omar E. Pol, Apr 30 2018
E.g.f.: e^x - 1. - Francois Oger, Oct 26 2019
a(n) = 1-A000007(n). - Chai Wah Wu, Nov 14 2022

Extensions

Entry edited at the suggestion of Robert G. Wilson v by N. J. A. Sloane, Aug 16 2015

A005132 Recamán's sequence (or Recaman's sequence): a(0) = 0; for n > 0, a(n) = a(n-1) - n if nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + n.

Original entry on oeis.org

0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24, 8, 25, 43, 62, 42, 63, 41, 18, 42, 17, 43, 16, 44, 15, 45, 14, 46, 79, 113, 78, 114, 77, 39, 78, 38, 79, 37, 80, 36, 81, 35, 82, 34, 83, 33, 84, 32, 85, 31, 86, 30, 87, 29, 88, 28, 89, 27, 90, 26, 91, 157, 224, 156, 225, 155
Offset: 0

Views

Author

N. J. A. Sloane and Simon Plouffe, May 16 1991

Keywords

Comments

The name "Recamán's sequence" is due to N. J. A. Sloane, not the author!
I conjecture that every number eventually appears - see A057167, A064227, A064228. - N. J. A. Sloane. That was written in 1991. Today I'm not so sure that every number appears. - N. J. A. Sloane, Feb 26 2017
As of Jan 25 2018, the first 13 missing numbers are 852655, 930058, 930557, 964420, 966052, 966727, 969194, 971330, 971626, 971866, 972275, 972827, 976367, ... For further information see the "Status Report" link. - Benjamin Chaffin, Jan 25 2018
From David W. Wilson, Jul 13 2009: (Start)
The sequence satisfies [1] a(n) >= 0, [2] |a(n)-a(n-1)| = n, and tries to avoid repeats by greedy choice of a(n) = a(n-1) -+ n.
This "wants" to be an injection on N = {0, 1, 2, ...}, as it attempts to avoid repeats by choice of a(n) = a(n-1) + n when a(n) = a(n-1) - n is a repeat.
Clearly, there are injections satisfying [1] and [2], e.g., a(n) = n(n+1)/2.
Is there a lexicographically earliest injection satisfying [1] and [2]? (End)
Answer: Yes, of course: The set of injections satisfying [1] and [2] is not empty, so there's a lexicographically least element. More concretely, it starts with the same 23 terms a(0..22) which are known to be minimal, but after a(22) = 41 it has to go on with a(23) = 41 + 23 = 64, since choosing "-" here necessarily yields a non-injective sequence. See A171884. - M. F. Hasler, Apr 01 2019
It appears that a(n) is also the value of "x" and "y" of the endpoint of the L-toothpick structure mentioned in A210606 after n-th stage. - Omar E. Pol, Mar 24 2012
Of course this is not a permutation of the integers: the first repeated term is 42 = a(24) = a(20). - M. F. Hasler, Nov 03 2014. Also 43 = a(18) = a(26). - Jon Perry, Nov 06 2014
Of all the sequences in the OEIS, this one is my favorite to listen to. Click the "listen" button at the top, set the instrument to "103. FX 7 (Echoes)", click "Save", and open the MIDI file with a program like QuickTime Player 7. - N. J. A. Sloane, Aug 08 2017
This sequence cycles clockwise around the OEIS logo. - Ryan Brooks, May 09 2020

Examples

			Consider n=6. We have a(5)=7 and try to subtract 6. The result, 1, is certainly positive, but we cannot use it because 1 is already in the sequence. So we must add 6 instead, getting a(6) = 7 + 6 = 13.
		

References

  • Alex Bellos and Edmund Harriss, Visions of the Universe (2016), Unnumbered pages. Includes Harriss's illustration of the first 65 steps drawn as a spiral.
  • Benjamin Chaffin, N. J. A. Sloane, and Allan Wilks, On sequences of Recaman type, paper in preparation, 2006.
  • Bernardo Recamán Santos, letter to N. J. A. Sloane, Jan 29 1991
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A057165 (addition steps), A057166 (subtraction steps), A057167 (steps to hit n), A008336, A046901 (simplified version), A064227 (records for reaching n), A064228 (value of n that take a record number of steps to reach), A064284 (no. of times n appears), A064290 (heights of terms), A064291 (record highs), A119632 (condensed version), A063733, A079053, A064288, A064289, A064387, A064388, A064389, A228474 (bidirectional version).
A065056 gives partial sums, A160356 gives first differences.
A row of A066201.
Cf. A171884 (injective variant).
See A324784, A324785, A324786 for the "low points".

Programs

  • Haskell
    import Data.Set (Set, singleton, notMember, insert)
    a005132 n = a005132_list !! n
    a005132_list = 0 : recaman (singleton 0) 1 0 where
       recaman :: Set Integer -> Integer -> Integer -> [Integer]
       recaman s n x = if x > n && (x - n) `notMember` s
                          then (x-n) : recaman (insert (x-n) s) (n+1) (x-n)
                          else (x+n) : recaman (insert (x+n) s) (n+1) (x+n)
    -- Reinhard Zumkeller, Mar 14 2011
    
  • MATLAB
    function a=A005132(m)
    % m=max number of terms in a(n). Offset n:0
    a=zeros(1,m);
    for n=2:m
        B=a(n-1)-(n-1);
        C=0.^( abs(B+1) + (B+1) );
        D=ismember(B,a(1:n-1));
        a(n)=a(n-1)+ (n-1) * (-1)^(C + D -1);
    end
    % Adriano Caroli, Dec 26 2010
    
  • Maple
    h := array(1..100000); maxt := 100000; a := [1]; ad := [1]; su := []; h[1] := 1; for nx from 2 to 500 do t1 := a[nx-1]-nx; if t1>0 and h[t1] <> 1 then su := [op(su), nx]; else t1 := a[nx-1]+nx; ad := [op(ad), nx]; fi; a := [op(a),t1]; if t1 <= maxt then h[t1] := 1; fi; od: # a is A005132, ad is A057165, su is A057166
    A005132 := proc(n)
        option remember; local a, found, j;
        if n = 0 then return 0 fi;
        a := procname(n-1) - n ;
        if a <= 0 then return a+2*n fi;
        found := false;
        for j from 0 to n-1 while not found do
            found := procname(j) = a;
        od;
        if found then a+2*n else a fi;
    end:
    seq(A005132(n), n=0..70); # R. J. Mathar, Apr 01 2012 (reformatted by Peter Luschny, Jan 06 2019)
  • Mathematica
    a = {1}; Do[ If[ a[ [ -1 ] ] - n > 0 && Position[ a, a[ [ -1 ] ] - n ] == {}, a = Append[ a, a[ [ -1 ] ] - n ], a = Append[ a, a[ [ -1 ] ] + n ] ], {n, 2, 70} ]; a
    (* Second program: *)
    f[s_List] := Block[{a = s[[ -1]], len = Length@s}, Append[s, If[a > len && !MemberQ[s, a - len], a - len, a + len]]]; Nest[f, {0}, 70] (* Robert G. Wilson v, May 01 2009 *)
    RecamanSeq[i_Integer] := Fold[With[{lst=Last@#, len=Length@#}, Append[#, If[lst > len && !MemberQ[#, lst - len], lst - len, lst + len]]] &, {0}, Range@i]; RecamanSeq[10^5] (* Mikk Heidemaa, Nov 02 2024 *)
  • PARI
    a(n)=if(n<2,1,if(abs(sign(a(n-1)-n)-1)+setsearch(Set(vector(n-1,i,a(i))),a(n-1)-n),a(n-1)+n,a(n-1)-n))  \\ Benoit Cloitre
    
  • PARI
    A005132(N=1000,show=0)={ my(s,t); for(n=1,N, s=bitor(s,1<M. F. Hasler, May 11 2008, updated M. F. Hasler, Nov 03 2014
    
  • Python
    l=[0]
    for n in range(1, 101):
        x=l[n - 1] - n
        if x>0 and not x in l: l+=[x, ]
        else: l+=[l[n - 1] + n]
    print(l) # Indranil Ghosh, Jun 01 2017
    
  • Python
    def recaman(n):
      seq = []
      for i in range(n):
        if(i == 0): x = 0
        else: x = seq[i-1]-i
        if(x>=0 and x not in seq): seq+=[x]
        else: seq+=[seq[i-1]+i]
      return seq
    print(recaman(1000)) # Ely Golden, Jun 14 2018
    
  • Python
    from itertools import count, islice
    def A005132_gen(): # generator of terms
        a, aset = 0, set()
        for n in count(1):
            yield a
            aset.add(a)
            a = b if (b:=a-n)>=0 and b not in aset else a+n
    A005132_list = list(islice(A005132_gen(),30)) # Chai Wah Wu, Sep 15 2022

Formula

a(k) = A000217(k) - 2*Sum_{i=1..n} A057166(i), for A057166(n) <= k < A057166(n+1). - Christopher Hohl, Jan 27 2019

Extensions

Allan Wilks, Nov 06 2001, computed 10^15 terms of this sequence. At this point all the numbers below 852655 had appeared, but 852655 = 5*31*5501 was missing.
After 10^25 terms of A005132 the smallest missing number is still 852655. - Benjamin Chaffin, Jun 13 2006
Even after 7.78*10^37 terms, the smallest missing number is still 852655. - Benjamin Chaffin, Mar 28 2008
Even after 4.28*10^73 terms, the smallest missing number is still 852655. - Benjamin Chaffin, Mar 22 2010
Even after 10^230 terms, the smallest missing number is still 852655. - Benjamin Chaffin, 2018
Changed "positive" in definition to "nonnegative". - N. J. A. Sloane, May 04 2020

A019590 Fermat's Last Theorem: a(n) = 1 if x^n + y^n = z^n has a nontrivial solution in integers, otherwise a(n) = 0.

Original entry on oeis.org

1, 1, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 1

Views

Author

Keywords

Comments

a(n) is the Hankel transform of A000045(n), n>=1 (Fibonacci numbers). See A055879 for the definition of Hankel transform. - Wolfdieter Lang, Jan 23 2007
1, -1, 0, 0, 0, ... is the convolutional inverse of the all-ones sequence. - Tanya Khovanova, Jun 29 2007
Also parity of the Euler totient function A000010. - Omar E. Pol, Jan 15 2012
a(n-1) gives the row sums of A048994. - Wolfdieter Lang, May 09 2017
Decimal expansion of 11/10. - Franklin T. Adams-Watters, Mar 08 2019

References

  • A. D. Aczel, Fermat's Last Theorem, Four Walls Eight Windows NY 1996.
  • A. C. Clarke, The Last Theorem, Gollancz SF 2004.
  • B. Cipra, What's Happening in the Mathematical Sciences 1994 Vol. 2, "A Truly Remarkable Proof" pp. 3-8 AMS Providence RI.
  • B. Cipra, What's Happening in the Mathematical Sciences 1995-6 Vol. 3, 'Fermat's Theorem-At Last' pp. 2-13 AMS Providence RI.
  • J. Coates and S.-T. Yau (Eds), Elliptic Curves, Modular Forms and Fermat's last Theorem, International Press Boston MA 1998.
  • G. Cornell, J. H. Silverman and G. Stevens (Eds), Modular Forms and Fermat's last Theorem, Springer NY 2000.
  • K. J. Devlin, Mathematics: The New Golden Age, Chapter 10, Columbia Univ. Press NY 1999.
  • L. E. Dickson, History of the Theory of Numbers. Carnegie Institute Public. 256, Washington, DC, Vol. 1, 1919; Vol. 2, 1920; Vol. 3, 1923, see vol. 2, p. 731.
  • H. M. Edwards, Fermat's Last Theorem, Springer, 1977.
  • G. Giorello & C. Sinigaglia, "Fermat: De défis en conjectures", Les génies de la science No. 32 Aug-Oct 2007, pp. 82-100, Pour la Science, Paris.
  • C. Goldstein, "Le Théorème de Fermat", La Recherche, Vol. Mar 25 1994, pp. 268-275, Paris.
  • C. Goldstein, "Le Théorème de Fermat enfin démontré", Chapter IX pp. 111-129 in 'Histoire Des Nombres', La Recherche, Tallandier, Paris 2007.
  • Y. Hellegouarch, "Fermat Vaincu", Quadrature No. 22 pp. 37-55 Editions du choix Argenteuil (France) 1995.
  • Y. Hellegouarch, "Fermat enfin démontré", Pour la Science, No. 220, 1996 pp. 92-97 Paris.
  • Y. Hellegouarch, Invitation aux mathématiques de Fermat-Wiles, Dunod Paris 2001.
  • Y. Hellegouarch, "L'Enigme du Theoreme de Fermat" pp. 31-41 in 'Qu'est-ce que l'Univers?", Université de tous les savoirs, Vol. 4 (Edit. Y. Michaud), Odile Jacob Paris 2001.
  • Y. Hellegouarch, Invitation to the Mathematics of Fermat-Wiles, Academic Press NY 2001.
  • P. Hoffman, The Man Who Loved Only Numbers, pp. 183-200, Hyperion NY 1998
  • W. Lindsay, Fermat's Last Theorem, A Perfect Proof, Lulu Press, Morrisville NC 2005.
  • L. J. Mordell, Three lectures on Fermat's last theorem, Cambr. Univ. Press 1921 (Reprinted by The Scholarly Pub. Office, Univ. of Michigan Library 2005).
  • C. J. Mozzochi, The Fermat Diary, AMS Providence RI 2000.
  • C. J. Mozzochi, The Fermat Proof, New Bern NC 2004.
  • V. K. Murty, Seminar on Fermat's Last Theorem, Amer. Math. Soc. Providence RI 1995.
  • P. Odifreddi, The Mathematical Century, Chapter 2.14 "Number Theory: Wiles' Proof of Fermat's Last Theorem (1995)" p. 82 Princeton Univ. Press NJ 2004.
  • I. Peterson, The Mathematical Tourist, pp. 234-238, W. H. Freeman/Owl Book NY 2001.
  • I. Peterson, "A Marginal Note" in Islands of Truths, pp. 280-285, W. H. Freeman NY 1990.
  • A. van der Poorten, Notes on Fermat's Last Theorem, Wiley NY 1996
  • J. Propp, Who Proved Fermat's Last Theorem? Princeton Univ. Press NJ 2005.
  • P. Ribenboim, 13 Lectures on Fermat's Last Theorem, Springer, 1979.
  • P. Ribenboim, Fermat's Last Theorem for Amateurs, Springer Verlag NY 1999.
  • R. Schoof, "Wiles' proof of the Taniyama-Weil conjecture for semi-stable elliptic curves over Q", Chap. 14 in 'Ou En Sont Les Mathématiques ?' Soc. Math. de France (SMF), Vuibert, Paris 2002.
  • S. Singh, Fermat's Enigma, Walker and Co. NY 1997.
  • I. Stewart, From Here To Infinity, Chapter 3 "Marginal Interest" pp. 25-48 OUP Oxford 1996.
  • I. Stewart and D. Tall, Algebraic Number Theory and Fermat's Last Theorem, A. K. Peters Natick MA 2001.
  • G. R. Talbott, Fermat's Last Theorem, Lotus Press WI 1991.
  • R. Van Vo, Fermat's Last Theorem, AuthorHouse, Bloomington IN 2002.
  • J. Vigouroux et al., Une aventure mathématique, le théorème de Fermat, BT2 series No. 6, PEMF Mouans-Sartoux(France) 1998.

Crossrefs

INVERT transform gives Fibonacci numbers, A000045.
Convolution inverse of A062157. Dirichlet convolution inverse of A154269.
Cf. A229382, A229383 (near-miss counterexamples to FLT).
Cf. A048994 (row sums).
Cf. A008683.

Programs

  • PARI
    {a(n) = (n==1) + (n==2)}; /* Michael Somos, Jul 05 2009 */

Formula

a(n) = (-1)^n*Sum_{k=0..floor(n/2)} (-1)^A010060(n-2k) mod (C(n, 2k), 2). - Paul Barry, Jan 03 2005
Euler transform of length 2 sequence [1, -1]. - Michael Somos, Jul 05 2009
a(n) is multiplicative with a(2) = 1, a(2^e) = 0 if e > 1, a(p^e) = 0^e if p > 2. - Michael Somos, Jul 05 2009
G.f.: x + x^2 = x * (1 - x^2) / (1 - x). - Michael Somos, Jul 05 2009
Dirichlet g.f.: 1 + 2^(-s). - Michael Somos, Jul 05 2009
a(n) = A000035(A000010(n)). - Omar E. Pol, Oct 28 2013
a(n) = Sum_{d|n} mu(n/d) * gcd(d,2). - Ridouane Oudra, May 30 2025

A007395 Constant sequence: the all 2's sequence.

Original entry on oeis.org

2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
Offset: 1

Views

Author

Keywords

Comments

Continued fraction for 1 + sqrt(2). - Philippe Deléham, Nov 14 2006
a(n) = A213999(n,1). - Reinhard Zumkeller, Jul 03 2012
The least witness function W(k) is defined for odd composite numbers k. The sequence W(k) does not have its own entry in the OEIS because W(k) = 2 for all k with 9 <= k < 2047; then W(2047)=3. Cf. A089105. - N. J. A. Sloane, Sep 17 2014
a(n) = A254858(n-1,1). - Reinhard Zumkeller, Feb 09 2015
a(n) = number of permutations of length n+2 having exactly one ascent such that the first element the permutation is 2. - Ran Pan, Apr 20 2015
With alternating signs, this is the sequence of determinants of the 3 X 3 matrices m with m(i,j) = Fibonacci(n+i+j-2)^2. - Michel Marcus, Dec 23 2015
For p = prime(n+2), a(n) = ord_p(H_(p-1)), where ord_p denotes the p-adic valuation and H_i = 1 + 1/2 + ... + 1/i is a harmonic sum, except for n = 1944 and n = 157504, where ord_p(H_(p-1)) = 3, and any other term of A088164 that may exist (see Conrad link). The sequence a(n) = ord_p(H_(p-1)) does not have its own entry in the OEIS. - Felix Fröhlich, Mar 16 2016
This sequence is the only infinite bounded sequence of positive integers such that a(n) = (a(n-1) + a(n-2)) / gcd(a(n-1), a(n-2)) for all n >= 2. - Bernard Schott, Dec 28 2018

References

  • Titu Andreescu and Dorin Andrica, Number Theory, Birkhäuser, 2009, from 1999 Russian Mathematical Olympiad, p. 347.
  • Paulo Ribenboim, My Numbers, My Friends: Popular Lectures on Number Theory, Springer-Verlag, NY, 2000, p. 6.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

Formula

G.f.: 2/(1-x), and e.g.f.: 2*e^x. - Mohammad K. Azarian, Dec 22 2008
a(n) = A000005(A000040(n)). - Omar E. Pol, Feb 28 2018
a(n) = A002061(n) - A165900(n). - Torlach Rush, Feb 21 2019

A023531 a(n) = 1 if n is of the form m(m+3)/2, otherwise 0.

Original entry on oeis.org

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

Views

Author

Clark Kimberling, Jun 14 1998

Keywords

Comments

Can be read as table: a(n,m) = 1 if n = m >= 0, else 0 (unit matrix).
a(n) = number of 1's between successive 0's (see also A005614, A003589 and A007538). - Eric Angelini, Jul 06 2005
Triangle T(n,k), 0 <= k <= n, read by rows, given by A000004 DELTA A000007 where DELTA is the operator defined in A084938. - Philippe Deléham, Jan 03 2009
Sequence B is called a reverse reluctant sequence of sequence A, if B is triangle array read by rows: row number k lists first k elements of the sequence A in reverse order.
A023531 is reverse reluctant sequence of sequence A000007. - Boris Putievskiy, Jan 11 2013
Also the Bell transform (and the inverse Bell transform) of 0^n (A000007). For the definition of the Bell transform see A264428. - Peter Luschny, Jan 19 2016
This is the turn sequence of the triangle spiral. To form the spiral: go a unit step forward, turn left a(n)*120 degrees, and repeat. The triangle sides are the runs of a(n)=0 (no turn). The sequence can be generated by a morphism with a special symbol S for the start of the sequence: S -> S,1; 1 -> 0,1; 0->0. The expansion lengthens each existing side and inserts a new unit side at the start. See the Fractint L-system in the links to draw the spiral this way. - Kevin Ryde, Dec 06 2019

Examples

			As a triangle:
       1
      0 1
     0 0 1
    0 0 0 1
   0 0 0 0 1
  0 0 0 0 0 1
G.f. = 1 + x^2 + x^5 + x^9 + x^14 + x^20 + x^27 + x^35 + x^44 + x^54 + ...
From _Kevin Ryde_, Dec 06 2019: (Start)
.
              1            Triangular spiral: start at S;
             / \             go a unit step forward,
            0   0   .        turn left a(n)*120 degrees,
           /     \   .       repeat.
          0   1   0   .
         /   / \   \   \   Each side's length is 1 greater
        0   0   0   0   0    than that of the previous side.
       /   /     \   \   \
      0   0   S---1   0   0
     /   /             \   \
    0   1---0---0---0---1   0
   /                         \
  1---0---0---0---0---0---0---1
(End)
		

Crossrefs

Programs

  • Haskell
    a023531 n = a023531_list !! n
    a023531_list = concat $ iterate ([0,1] *) [1]
    instance Num a => Num [a] where
       fromInteger k = [fromInteger k]
       (p:ps) + (q:qs) = p + q : ps + qs
       ps + qs         = ps ++ qs
       (p:ps) * qs'@(q:qs) = p * q : ps * qs' + [p] * qs
        *                = []
    -- Reinhard Zumkeller, Apr 02 2011
    
  • Maple
    seq(op([0$m,1]),m=0..10); # Robert Israel, Jan 18 2015
    # alternative
    A023531 := proc(n)
        option remember ;
        local m,t ;
        for m from 0 do
            t := m*(m+3)/2 ;
            if t > n then
                return 0 ;
            elif t = n then
                return 1 ;
            end if;
        end do:
    end proc:
    seq(A023531(n),n=0..40) ; # R. J. Mathar, May 15 2025
  • Mathematica
    If[IntegerQ[(Sqrt[9+8#]-3)/2],1,0]&/@Range[0,100] (* Harvey P. Dale, Jul 27 2011 *)
    a[ n_] := If[ n < 0, 0, Boole @ IntegerQ @ Sqrt[ 8 n + 9]]; (* Michael Somos, May 17 2014 *)
    a[ n_] := SeriesCoefficient[ (EllipticTheta[ 2, 0, x^(1/2)] / (2 x^(1/8)) - 1) / x, {x, 0, n}]; (* Michael Somos, May 17 2014 *)
  • PARI
    {a(n) = if( n<0, 0, issquare(8*n + 9))}; /* Michael Somos, May 17 2014 */
    
  • PARI
    A023531(n)=issquare(8*n+9) \\ M. F. Hasler, Apr 12 2018
    
  • Python
    from math import isqrt
    def A023531(n): return int((k:=n+1<<1)==(m:=isqrt(k))*(m+1)) # Chai Wah Wu, Nov 09 2024
  • Sage
    def A023531_row(n) :
        if n == 0: return [1]
        return [0] + A023531_row(n-1)
    for n in (0..9): print(A023531_row(n))  # Peter Luschny, Jul 22 2012
    

Formula

If (floor(sqrt(2*n))-(2*n/(floor(sqrt(2*n)))) = -1, 1, 0). - Gerald Hillier, Sep 11 2005
a(n) = 1 - A023532(n); a(n) = 1 - mod(floor(((10^(n+2) - 10)/9)10^(n+1 - binomial(floor((1+sqrt(9+8n))/2), 2) - (1+floor(log((10^(n+2) - 10)/9, 10))))), 10). - Paul Barry, May 25 2004
a(n) = floor((sqrt(9+8n)-1)/2) - floor((sqrt(1+8n)-1)/2). - Paul Barry, May 25 2004
a(n) = round(sqrt(2n+3)) - round(sqrt(2n+2)). - Hieronymus Fischer, Aug 06 2007
a(n) = ceiling(2*sqrt(2n+3)) - floor(2*sqrt(2n+2)) - 1. - Hieronymus Fischer, Aug 06 2007
From Franklin T. Adams-Watters, Jun 29 2009: (Start)
G.f.: (1/2 x^{-1/8}theta_2(0,x^{1/2}) - 1)/x, where theta_2 is a Jacobi theta function.
G.f. for triangle: Sum T(n,k) x^n y^k = 1/(1-x*y). Sum T(n,k) x^n y^k / n! = Sum T(n,k) x^n y^k / k! = exp(x*y). Sum T(n,k) x^n y^k / (n! k!) = I_0(2*sqrt(x*y)), where I is the modified Bessel function of the first kind. (End)
a(n) = A000007(m), where m=(t*t+3*t+4)/2-n, t=floor((-1+sqrt(8*n-7))/2). - Boris Putievskiy, Jan 11 2013
The row polynomials are p(n,x) = x^n = (-1)^n n!Lag(n,-n,x), the normalized, associated Laguerre polynomials of order -n. As the prototypical Appell sequence with e.g.f. exp(x*y), its raising operator is R = x and lowering operator, L = d/dx, i.e., R p(n,x) = p(n+1,x), and L p(n,x) = n * p(n-1,x). - Tom Copeland, May 10 2014
a(n) = A010054(n+1) if n >= 0. - Michael Somos, May 17 2014
a(n) = floor(sqrt(2*(n+1)+1/2)-1/2) - floor(sqrt(2*n+1/2)-1/2). - Mikael Aaltonen, Jan 18 2015
a(n) = A003057(n+3) - A003057(n+2). - Robert Israel, Jan 18 2015
a(A000096(n)) = 1; a(A007701(n)) = 0. - Reinhard Zumkeller, Feb 14 2015
Characteristic function of A000096. - M. F. Hasler, Apr 12 2018
Sum_{k=1..n} a(k) ~ sqrt(2*n). - Amiram Eldar, Jan 13 2024

A344607 Number of integer partitions of n with reverse-alternating sum >= 0.

Original entry on oeis.org

1, 1, 2, 2, 4, 4, 8, 8, 15, 16, 27, 29, 48, 52, 81, 90, 135, 151, 220, 248, 352, 400, 553, 632, 859, 985, 1313, 1512, 1986, 2291, 2969, 3431, 4394, 5084, 6439, 7456, 9357, 10836, 13479, 15613, 19273, 22316, 27353, 31659, 38558, 44601, 53998, 62416, 75168
Offset: 0

Views

Author

Gus Wiseman, May 29 2021

Keywords

Comments

The reverse-alternating sum of a partition (y_1,...,y_k) is Sum_i (-1)^(k-i) y_i.
Also the number of reversed integer partitions of n with alternating sum >= 0.
A formula for the reverse-alternating sum of a partition is: (-1)^(k-1) times the number of odd parts in the conjugate partition, where k is the number of parts. So a(n) is the number of integer partitions of n whose conjugate parts are all even or whose length is odd. By conjugation, this is also the number of integer partitions of n whose parts are all even or whose greatest part is odd.
All integer partitions have alternating sum >= 0, so the non-reversed version is A000041.
Is this sequence weakly increasing? In particular, is A344611(n) <= A160786(n)?

Examples

			The a(1) = 1 through a(8) = 15 partitions:
  (1)  (2)   (3)    (4)     (5)      (6)       (7)        (8)
       (11)  (111)  (22)    (221)    (33)      (322)      (44)
                    (211)   (311)    (222)     (331)      (332)
                    (1111)  (11111)  (321)     (421)      (422)
                                     (411)     (511)      (431)
                                     (2211)    (22111)    (521)
                                     (21111)   (31111)    (611)
                                     (111111)  (1111111)  (2222)
                                                          (3311)
                                                          (22211)
                                                          (32111)
                                                          (41111)
                                                          (221111)
                                                          (2111111)
                                                          (11111111)
		

Crossrefs

The non-reversed version is A000041.
The opposite version (rev-alt sum <= 0) is A027187, ranked by A028260.
The strict case for n > 0 is A067659 (even bisection: A344650).
The ordered version appears to be A116406 (even bisection: A114121).
The odd bisection is A160786.
The complement is counted by A344608.
The Heinz numbers of these partitions are A344609 (complement: A119899).
The even bisection is A344611.
A000070 counts partitions with alternating sum 1 (reversed: A000004).
A000097 counts partitions with alternating sum 2 (reversed: A120452).
A035363 counts partitions with alternating sum 0, ranked by A000290.
A103919 counts partitions by sum and alternating sum.
A316524 is the alternating sum of prime indices of n (reversed: A344616).
A325534/A325535 count separable/inseparable partitions.
A344610 counts partitions by sum and positive reverse-alternating sum.
A344612 counts partitions by sum and reverse-alternating sum.
A344618 gives reverse-alternating sums of standard compositions.

Programs

  • Mathematica
    sats[y_]:=Sum[(-1)^(i-Length[y])*y[[i]],{i,Length[y]}];
    Table[Length[Select[IntegerPartitions[n],sats[#]>=0&]],{n,0,30}]

Formula

a(n) + A344608(n) = A000041(n).
a(2n+1) = A160786(n).

A172236 Array A(n,k) = n*A(n,k-1) + A(n,k-2) read by upward antidiagonals, starting A(n,0) = 0, A(n,1) = 1.

Original entry on oeis.org

0, 0, 1, 0, 1, 1, 0, 1, 2, 2, 0, 1, 3, 5, 3, 0, 1, 4, 10, 12, 5, 0, 1, 5, 17, 33, 29, 8, 0, 1, 6, 26, 72, 109, 70, 13, 0, 1, 7, 37, 135, 305, 360, 169, 21, 0, 1, 8, 50, 228, 701, 1292, 1189, 408, 34, 0, 1, 9, 65, 357, 1405, 3640, 5473, 3927, 985, 55, 0, 1, 10, 82, 528, 2549, 8658, 18901, 23184, 12970, 2378, 89, 0, 1, 11, 101, 747, 4289, 18200, 53353, 98145, 98209, 42837, 5741, 144
Offset: 1

Views

Author

Roger L. Bagula, Jan 29 2010

Keywords

Comments

Equals A073133 with an additional column A(.,0).
If the first column and top row are deleted, antidiagonal reading yields A118243.
Adding a top row of 1's and antidiagonal reading downwards yields A157103.
Antidiagonal sums are 0, 1, 2, 5, 12, 32, 93, 297, 1035, 3911, 15917, 69350, ....
From Jianing Song, Jul 14 2018: (Start)
All rows have strong divisibility, that is, gcd(A(n,k_1), A(n,k_2)) = A(n,gcd(k_1,k_2)) holds for all k_1, k_2 >= 0.
Let E(n,m) be the smallest number l such that m divides A(n,l), we have: for odd primes p that are not divisible by n^2 + 4, E(n,p) divides p - ((n^2+4)/p) if p == 3 (mod 4) and (p - ((n^2+4)/p))/2 if p == 1 (mod 4). E(n,p) = p for odd primes p that are divisible by n^2 + 4. E(n,2) = 2 for even n and 3 for odd n. Here ((n^2+4)/p) is the Legendre symbol. A prime p such that p^2 divides T(n,E(n,p)) is called an n-Wall-Sun-Sun prime.
E(n,p^e) <= p^(e-1)*E(n,p) for all primes p. If p^2 does not divide A(n, E(n,p)), then E(n,p^e) = p^(e-1)*E(n,p) for all exponent e. Specially, for primes p >= 5 that are divisible by n^2 + 4, p^2 is never divisible by A(n,p), so E(n,p^e) = p^e as described above. E(n,m_1*m_2) = lcm(E(n,m_1),E(n,m_2)) if gcd(m_1,m_2) = 1.
Let pi(n,m) be the Pisano period of A(n, k) modulo m, i.e, the smallest number l such that A(n, k+1) == T(n,k) (mod m) holds for all k >= 0, we have: for odd primes p that are not divisible by n^2 - 4, pi(n,p) divides p - 1 if ((n^2+4)/p) = 1 and 2(p+1) if ((n^2+4)/p) = -1. pi(n,p) = 4p for odd primes p that are divisible by n^2 + 4. pi(n,2) = 2 even n and 3 for odd n.
pi(n,p^e) <= p^(e-1)*pi(n,p) for all primes p. If p^2 does not divide A(n, E(n,p)), then pi(n,p^e) = p^(e-1)*pi(n,p) for all exponent e. Specially, for primes p >= 5 that are divisible by n^2 + 4, p^2 is never divisible by A(n, p), so pi(n,p^e) = 4p^e as described above. pi(n,m_1*m_2) = lcm(pi(n,m_1), pi(n,m_2)) if gcd(m_1,m_2) = 1.
If n != 2, the largest possible value of pi(n,m)/m is 4 for even n and 6 for odd n. For even n, pi(n,p^e) = 4p^e; for odd n, pi(n,2p^e) = 12p^e, where p is any odd prime factor of n^2 + 4. For n = 2 it is 8/3, obtained by m = 3^e.
Let z(n,m) be the number of zeros in a period of A(n, k) modulo m, i.e., z(n,m) = pi(n,m)/E(n,m), then we have: z(n,p) = 4 for odd primes p that are divisible by n^2 + 4. For other odd primes p, z(n,p) = 4 if E(n,p) is odd; 1 if E(n,p) is even but not divisible by 4; 2 if E(n,p) is divisible by 4; see the table below. z(n,2) = z(n,4) = 1.
Among all values of z(n,p) when p runs through all odd primes that are not divisible by n^2 + 4, we have:
((n^2+4)/p)...p mod 8....proportion of 1.....proportion of 2.....proportion of 4
......1..........1......1/6 (conjectured)...2/3 (conjectured)...1/6 (conjectured)*
......1..........5......1/2 (conjectured)...........0...........1/2 (conjectured)*
......1.........3,7.............1...................0...................0
.....-1.........1,5.............0...................0...................1
.....-1.........3,7.............0...................1...................0
* The result is that among all odd primes that are not divisible by n^2 + 4, 7/24 of them are with z(n,p) = 1, 5/12 are with z(n,p) = 2 and 7/24 are with z(n,p) = 4 if n^2 + 4 is a twice a square; 1/3 of them are with z(n,p) = 1, 1/3 are with z(n,p) = 2 and 1/3 are with z(n,p) = 4 otherwise. [Corrected by Jianing Song, Jul 06 2019]
z(n,p^e) = z(n,p) for all odd primes p; z(n,2^e) = 1 for even n and 2 for odd n, e >= 3.
(End)
From Michael A. Allen, Mar 06 2023: (Start)
Removing the first (n=0) row of A352361 gives this sequence.
Row n is the n-metallonacci sequence.
A(n,k) is (for k>0) the number of tilings of a (k-1)-board (a board with dimensions (k-1) X 1) using unit squares and dominoes (with dimensions 2 X 1) if there are n kinds of squares available. (End)

Examples

			The array, A(n, k), starts in row n = 1 with columns k >= 0 as
  0      1      1      2      3      5      8
  0      1      2      5     12     29     70
  0      1      3     10     33    109    360
  0      1      4     17     72    305   1292
  0      1      5     26    135    701   3640
  0      1      6     37    228   1405   8658
  0      1      7     50    357   2549  18200
  0      1      8     65    528   4289  34840
  0      1      9     82    747   6805  61992
  0      1     10    101   1020  10301 104030
  0      1     11    122   1353  15005 166408
Antidiagonal triangle, T(n, k), begins as:
  0;
  0, 1;
  0, 1, 1;
  0, 1, 2,  2;
  0, 1, 3,  5,   3;
  0, 1, 4, 10,  12,   5;
  0, 1, 5, 17,  33,  29,    8;
  0, 1, 6, 26,  72, 109,   70,   13;
  0, 1, 7, 37, 135, 305,  360,  169,  21;
  0, 1, 8, 50, 228, 701, 1292, 1189, 408, 34;
		

Crossrefs

Rows n include: A000045 (n=1), A000129 (n=2), A006190 (n=3), A001076 (n=4), A052918 (n=5), A005668 (n=6), A054413 (n=7), A041025 (n=8), A099371 (n=9), A041041 (n=10), A049666 (n=11), A041061 (n=12), A140455 (n=13), A041085 (n=14), A154597 (n=15), A041113 (n=16), A178765 (n=17), A041145 (n=18), A243399 (n=19), A041181 (n=20). (Note that there are offset shifts for rows n = 5, 7, 8, 10, 12, 14, 16..20.)
Columns k include: A000004 (k=0), A000012 (k=1), A000027 (k=2), A002522 (k=3), A054602 (k=4), A057721 (k=5), A124152 (k=6).
Entry points for A(n,k) modulo m: A001177 (n=1), A214028 (n=2), A322907 (n=3).
Pisano period for A(n,k) modulo m: A001175 (n=1), A175181 (n=2), A175182 (n=3), A175183 (n=4), A175184 (n=5), A175185 (n=6).
Number of zeros in a period for A(n,k) modulo m: A001176 (n=1), A214027 (n=2), A322906 (n=3).
Sums include: A304357, A304359.
Similar to: A073133.

Programs

  • Magma
    A172236:= func< n,k | k le 1 select k else Evaluate(DicksonSecond(k-1,-1), n-k) >;
    [A172236(n,k): k in [0..n-1], n in [1..13]]; // G. C. Greubel, Sep 29 2024
    
  • Mathematica
    A172236[n_,k_]:=Fibonacci[k, n-k];
    Table[A172236[n, k], {n,15}, {k,0,n-1}]//Flatten
  • PARI
    A(n, k) = if (k==0, 0, if (k==1, 1, n*A(n, k-1) + A(n, k-2)));
    tabl(nn) = for(n=1, nn, for (k=0, nn, print1(A(n, k), ", ")); print); \\ Jianing Song, Jul 14 2018 (program from Michel Marcus; see also A316269)
    
  • PARI
    A(n, k) = ([n, 1; 1, 0]^k)[2, 1] \\ Jianing Song, Nov 10 2018
    
  • SageMath
    def A172236(n,k): return sum(binomial(k-j-1,j)*(n-k)^(k-2*j-1) for j in range(1+(k-1)//2))
    flatten([[A172236(n,k) for k in range(n)] for n in range(1,14)]) # G. C. Greubel, Sep 29 2024

Formula

A(n,k) = (((n + sqrt(n^2 + 4))/2)^k - ((n-sqrt(n^2 + 4))/2)^k)/sqrt(n^2 + 4), n >= 1, k >= 0. - Jianing Song, Jun 27 2018
For n >= 1, Sum_{i=1..k} 1/A(n,2^i) = ((u^(2^k-1) + v^(2^k-1))/(u + v)) * (1/A(n,2^k)), where u = (n + sqrt(n^2 + 4))/2, v = (n - sqrt(n^2 + 4))/2 are the two roots of the polynomial x^2 - n*x - 1. As a result, Sum_{i>=1} 1/A(n,2^i) = (n^2 + 4 - n*sqrt(n^2 + 4))/(2*n). - Jianing Song, Apr 21 2019
From G. C. Greubel, Sep 29 2024: (Start)
A(n, k) = F_{k}(n) (Fibonacci polynomials F_{n}(x)) (array).
T(n, k) = F_{k}(n-k) (antidiagonal triangle).
Sum_{k=0..n-1} T(n, k) = A304357(n) - (1-(-1)^n)/2.
Sum_{k=0..n-1} (-1)^k*T(n, k) = (-1)*A304359(n) + (1-(-1)^n)/2.
T(2*n, n) = A084844(n).
T(2*n+1, n+1) = A084845(n). (End)

Extensions

More terms from Jianing Song, Jul 14 2018

A142150 The nonnegative integers interleaved with 0's.

Original entry on oeis.org

0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, 41, 0, 42, 0, 43, 0
Offset: 0

Views

Author

Reinhard Zumkeller, Jul 15 2008

Keywords

Comments

Number of vertical pairs in a wheel with n equal sections. - Wesley Ivan Hurt, Jan 22 2012
Number of even terms of n-th row in the triangles A162610 and A209297. - Reinhard Zumkeller, Jan 19 2013
Also the result of writing n-1 in base 2 and multiplying the last digit with the number with its last digit removed. See A115273 and A257844-A257850 for generalization to other bases. - M. F. Hasler, May 10 2015
Also follows the rule: a(n+1) is the number of terms that are identical with a(n) for a(0..n-1). - Marc Morgenegg, Jul 08 2019

Crossrefs

Programs

Formula

a(n) = XOR{k AND (n-k): 0<=k<=n}.
a(n) = (n/2)*0^(n mod 2); a(2*n)=n and a(2*n+1)=0.
a(n) = floor(n^2/2) mod n. - Enrique Pérez Herrero, Jul 29 2009
a(n) = A027656(n-2). - Reinhard Zumkeller, Nov 05 2009
a(n) = Sum_{k=0..n} (k mod 2)*((n-k) mod 2). - Reinhard Zumkeller, Nov 05 2009
a(n+1) = A000217(n) mod A000027(n+1) = A000217(n) mod A001477(n+1). - Edgar Almeida Ribeiro (edgar.a.ribeiro(AT)gmail.com), May 19 2010
From Bruno Berselli, Oct 19 2010: (Start)
a(n) = n*(1+(-1)^n)/4.
G.f.: x^2/(1-x^2)^2.
a(n) = 2*a(n-2)-a(n-4) for n > 3.
Sum_{i=0..n} a(i) = (2*n*(n+1)+(2*n+1)*(-1)^n-1)/16 (see A008805). (End)
a(n) = -a(-n) = A195034(n-1)-A195034(-n-1). - Bruno Berselli, Oct 12 2011
a(n) = A000326(n) - A191967(n). - Reinhard Zumkeller, Jul 07 2012
a(n) = Sum_{i=1..n} floor((2*i-n)/2). - Wesley Ivan Hurt, Aug 21 2014
a(n-1) = floor(n/2)*(n mod 2), where (n mod 2) is the parity of n, or remainder of division by 2. - M. F. Hasler, May 10 2015
a(n) = A158416(n) - 1. - Filip Zaludek, Oct 30 2016
E.g.f.: x*sinh(x)/2. - Ilya Gutkovskiy, Oct 30 2016
a(n) = A000007(a(n-1)) + a(n-2) for n > 1. - Nicolas Bělohoubek, Oct 06 2024
Previous Showing 11-20 of 350 results. Next