login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A126024 Number of subsets of {1,2,3,...,n} whose sum is a square integer (including the empty subset). 12

%I #26 Nov 03 2023 11:06:56

%S 1,2,2,3,5,7,12,20,34,60,106,190,346,639,1183,2204,4129,7758,14642,

%T 27728,52648,100236,191294,365827,700975,1345561,2587057,4981567,

%U 9605777,18546389,35851756,69382558,134414736,260658770,505941852,982896850

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

%H Alois P. Heinz, <a href="/A126024/b126024.txt">Table of n, a(n) for n = 0..990</a> (terms n=1..100 from T. D. Noe)

%e 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.

%p b:= proc(n, i) option remember; (m->

%p `if`(n=0 or n=m, 1, `if`(n<0 or n>m, 0, b(n, i-1)+

%p `if`(i>n, 0, b(n-i, i-1)))))(i*(i+1)/2)

%p end:

%p a:= proc(n) option remember; `if`(n<0, 0, a(n-1)+

%p add(b(j^2-n, n-1), j=isqrt(n)..isqrt(n*(n+1)/2)))

%p end:

%p seq(a(n), n=0..50); # _Alois P. Heinz_, Feb 02 2017

%t 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 *)

%o (Haskell)

%o import Data.List (subsequences)

%o a126024 = length . filter ((== 1) . a010052 . sum) .

%o subsequences . enumFromTo 1

%o -- _Reinhard Zumkeller_, Feb 22 2012, Oct 27 2010

%Y Cf. A053632, A127542.

%Y Cf. A181522. - _Reinhard Zumkeller_, Oct 27 2010

%Y Cf. A010052, A284250.

%Y Row sums of A281871.

%K nonn

%O 0,2

%A _John W. Layman_, Feb 27 2007

%E Extended by _Ray Chandler_, Mar 05 2007

%E a(0)=1 prepended by _Alois P. Heinz_, Jan 30 2017

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 03:15 EDT 2024. Contains 371964 sequences. (Running on oeis4.)