cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-4 of 4 results.

A126024 Number of subsets of {1,2,3,...,n} whose sum is a square integer (including the empty subset).

Original entry on oeis.org

1, 2, 2, 3, 5, 7, 12, 20, 34, 60, 106, 190, 346, 639, 1183, 2204, 4129, 7758, 14642, 27728, 52648, 100236, 191294, 365827, 700975, 1345561, 2587057, 4981567, 9605777, 18546389, 35851756, 69382558, 134414736, 260658770, 505941852, 982896850
Offset: 0

Views

Author

John W. Layman, Feb 27 2007

Keywords

Examples

			The subsets of {1,2,3,4,5} that sum to a square are {}, {1}, {1,3}, {4}, {2,3,4}, {1,3,5} and {4,5}. Thus a(5)=7.
		

Crossrefs

Cf. A181522. - Reinhard Zumkeller, Oct 27 2010
Row sums of A281871.

Programs

  • Haskell
    import Data.List (subsequences)
    a126024 = length . filter ((== 1) . a010052 . sum) .
                              subsequences . enumFromTo 1
    -- Reinhard Zumkeller, Feb 22 2012, Oct 27 2010
  • Maple
    b:= proc(n, i) option remember; (m->
          `if`(n=0 or n=m, 1, `if`(n<0 or n>m, 0, b(n, i-1)+
          `if`(i>n, 0, b(n-i, i-1)))))(i*(i+1)/2)
        end:
    a:= proc(n) option remember; `if`(n<0, 0, a(n-1)+
          add(b(j^2-n, n-1), j=isqrt(n)..isqrt(n*(n+1)/2)))
        end:
    seq(a(n), n=0..50);  # Alois P. Heinz, Feb 02 2017
  • Mathematica
    g[n_] := Block[{p = Product[1 + z^i, {i, n}]},Sum[Boole[IntegerQ[Sqrt[k]]]*Coefficient[p, z, k], {k, 0, n*(n + 1)/2}]];Array[g, 35] (* Ray Chandler, Mar 05 2007 *)

Extensions

Extended by Ray Chandler, Mar 05 2007
a(0)=1 prepended by Alois P. Heinz, Jan 30 2017

A284249 Number T(n,k) of k-element subsets of [n] whose sum is a triangular number; triangle T(n,k), n>=0, 0<=k<=n, read by rows.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 2, 3, 3, 1, 1, 1, 3, 4, 5, 3, 1, 1, 1, 3, 5, 8, 6, 4, 1, 1, 1, 3, 7, 12, 11, 9, 4, 1, 1, 1, 3, 9, 16, 20, 18, 11, 5, 1, 1, 1, 4, 10, 22, 32, 35, 26, 14, 5, 1, 1, 1, 4, 12, 29, 48, 61, 55, 36, 17, 6, 1, 1, 1, 4, 14, 37, 70, 100, 106, 84, 48, 21, 6, 1, 1
Offset: 0

Views

Author

Alois P. Heinz, Mar 23 2017

Keywords

Examples

			Triangle T(n,k) begins:
  1;
  1, 1;
  1, 1,  1;
  1, 2,  1,  1;
  1, 2,  2,  1,  1;
  1, 2,  3,  3,  1,   1;
  1, 3,  4,  5,  3,   1,   1;
  1, 3,  5,  8,  6,   4,   1,  1;
  1, 3,  7, 12, 11,   9,   4,  1,  1;
  1, 3,  9, 16, 20,  18,  11,  5,  1,  1;
  1, 4, 10, 22, 32,  35,  26, 14,  5,  1, 1;
  1, 4, 12, 29, 48,  61,  55, 36, 17,  6, 1, 1;
  1, 4, 14, 37, 70, 100, 106, 84, 48, 21, 6, 1, 1;
		

Crossrefs

Second and third lower diagonals give: A008619(n+1), A008747(n+1).
Row sums give A284250.
T(2n,n) gives A284251.

Programs

  • Maple
    b:= proc(n, s) option remember; expand(`if`(n=0,
          `if`(issqr(8*s+1), 1, 0), b(n-1, s)+x*b(n-1, s+n)))
        end:
    T:= n-> (p-> seq(coeff(p, x, i), i=0..n))(b(n, 0)):
    seq(T(n), n=0..16);
  • Mathematica
    b[n_, s_] := b[n, s] = Expand[If[n == 0, If[IntegerQ @ Sqrt[8*s + 1], 1, 0], b[n - 1, s] + x*b[n - 1, s + n]]];
    T[n_] := Function [p, Table[Coefficient[p, x, i], {i, 0, n}]][b[n, 0]];
    Table[T[n], {n, 0, 16}] // Flatten (*Jean-François Alcover, May 29 2018, from Maple *)

A339507 Number of subsets of {1..n} whose sum is a decimal palindrome.

Original entry on oeis.org

1, 2, 4, 8, 15, 24, 32, 41, 55, 79, 126, 220, 406, 778, 1524, 3057, 6310, 13211, 27500, 56246, 113003, 224220, 442106, 870323, 1715503, 3391092, 6726084, 13382357, 26686192, 53286329, 106469764, 212803832, 425434124, 850676115, 1701169724, 3402169203, 6804150711, 13608072837, 27215890383, 54431527170
Offset: 0

Views

Author

Ilya Gutkovskiy, Dec 07 2020

Keywords

Examples

			a(5) = 24 subsets: {}, {1}, {2}, {3}, {4}, {5}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 3}, {2, 4}, {2, 5}, {3, 4}, {3, 5}, {4, 5}, {1, 2, 3}, {1, 2, 4}, {1, 2, 5}, {1, 3, 4}, {1, 3, 5}, {2, 3, 4}, {2, 4, 5} and {1, 2, 3, 5}.
		

Crossrefs

Programs

  • Python
    from itertools import combinations
    def a(n):
        ans = 0
        for r in range(n+1):
            for s in combinations(range(1,n+1),r):
                strss = str(sum(s))
                ans += strss==strss[::-1]
        return ans
    print([a(n) for n in range(21)]) # Michael S. Branicky, Dec 07 2020
    
  • Python
    from functools import lru_cache
    from itertools import combinations
    @lru_cache(maxsize=None)
    def A339507(n):
        pallist = set(i for i in range(1,n*(n+1)//2+1) if str(i) == str(i)[::-1])
        return 1 if n == 0 else A339507(n-1) + sum(sum(d)+n in pallist for i in range(n) for d in combinations(range(1,n),i)) # Chai Wah Wu, Dec 08 2020
    
  • Python
    from functools import lru_cache
    def cond(s): ss = str(s); return ss == ss[::-1]
    @lru_cache(maxsize=None)
    def b(n, s):
        if n == 0: return int(cond(s))
        return b(n-1, s) + b(n-1, s+n)
    a = lambda n: b(n, 0)
    print([a(n) for n in range(100)]) # Michael S. Branicky, Oct 05 2022

Extensions

a(23)-a(36) from Michael S. Branicky, Dec 08 2020
a(37)-a(39) from Chai Wah Wu, Dec 11 2020

A377123 Number of subsets of the first n nonzero triangular numbers whose sum is a nonzero triangular number.

Original entry on oeis.org

1, 2, 4, 5, 8, 13, 18, 29, 48, 81, 136, 228, 420, 747, 1326, 2468, 4520, 8296, 15232, 28196, 52504, 96936, 181699, 340998, 640091, 1207386, 2282956, 4328536, 8211989, 15623003, 29787092, 56831499, 108591159, 207851120, 398222781, 763760138, 1466661416, 2819529654, 5425826011, 10450403468
Offset: 1

Views

Author

Ilya Gutkovskiy, Oct 17 2024

Keywords

Examples

			a(5) = 8 subsets: {1}, {3}, {6}, {10}, {15}, {6, 15}, {1, 3, 6} and {3, 10, 15}.
		

Crossrefs

Programs

  • Python
    from math import isqrt
    from functools import cache
    def cond(s): k = 8*s+1; return s > 0 and isqrt(k)**2 == k
    def u(n): return n*(n+1)//2
    @cache
    def b(n, s):
        if n == 0: return int(cond(s))
        return b(n-1, s) + b(n-1, s+u(n))
    a = lambda n: b(n, 0)
    print([a(n) for n in range(1, 51)]) # Michael S. Branicky, Oct 18 2024

Extensions

a(23) and beyond from Michael S. Branicky, Oct 18 2024
Showing 1-4 of 4 results.