cp's OEIS Frontend

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

Showing 1-2 of 2 results.

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

A127542 Number of subsets of {1,2,3,...,n} whose sum is prime.

Original entry on oeis.org

0, 2, 4, 7, 12, 22, 42, 76, 139, 267, 516, 999, 1951, 3824, 7486, 14681, 28797, 56191, 108921, 210746, 410016, 804971, 1591352, 3153835, 6249154, 12380967, 24553237, 48731373, 96622022, 191012244, 376293782, 739671592, 1454332766, 2867413428, 5678310305
Offset: 1

Views

Author

Emeric Deutsch, Mar 03 2007

Keywords

Examples

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

Crossrefs

Row sums of A282516.

Programs

  • Haskell
    import Data.List (subsequences)
    a127542 = length . filter ((== 1) . a010051 . sum) .
                              subsequences . enumFromTo 1
    -- Reinhard Zumkeller, Feb 22 2012, Oct 27 2010
    
  • Maple
    with(combinat): a:=proc(n) local ct, pn, j:ct:=0: pn:=powerset(n): for j from 1 to 2^n do if isprime(add(pn[j][i],i=1..nops(pn[j]))) =true then ct:=ct+1 else ct:=ct fi: od: end: seq(a(n),n=1..18);
    # second Maple program:
    b:= proc(n, s) option remember; `if`(n=0,
         `if`(isprime(s), 1, 0), b(n-1, s)+b(n-1, s+n))
        end:
    a:= n-> b(n, 0):
    seq(a(n), n=1..44);  # Alois P. Heinz, Oct 22 2023
  • Mathematica
    g[n_] := Block[{p = Product[1 + z^i, {i, n}]},Sum[Boole[PrimeQ[k]]*Coefficient[p, z, k], {k, 0, n*(n + 1)/2}]];Array[g, 34] (* Ray Chandler, Mar 05 2007 *)
  • PARI
    a(n)=my(v=Vec(prod(i=1,n,x^i+1)),s);forprime(p=2,#v,s+=v[p]);s \\ Charles R Greathouse IV, Dec 19 2014
    
  • PARI
    first(n)=my(v=vector(n),P=1,s); for(k=1,n, P*=1+'x^n; s=0; forprime(p=2,k*(k+1)/2,s+=polcoeff(P,p)); v[k]=s); v \\ Charles R Greathouse IV, Dec 19 2014

Extensions

Extended by Ray Chandler, Mar 05 2007
Showing 1-2 of 2 results.