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.

A252897 Rainbow Squares: a(n) = number of ways to pair the integers 1 to 2n so that the sum of each pair is a square.

This page as a plain text file.
%I A252897 #62 Jun 18 2025 15:36:45
%S A252897 1,0,0,0,1,0,0,1,1,1,0,0,1,6,18,12,36,156,295,429,755,2603,7122,19232,
%T A252897 32818,54363,172374,384053,933748,1639656,4366714,20557751,83801506,
%U A252897 188552665,399677820,640628927,2175071240,8876685569,32786873829,108039828494,351090349416
%N A252897 Rainbow Squares: a(n) = number of ways to pair the integers 1 to 2n so that the sum of each pair is a square.
%C A252897 The original sequence is from Henri Picciotto, who asked for which n is such a pairing possible: A253472.
%C A252897 The name "rainbow squares" refers to the use of this problem in the elementary school classroom where children draw colored connecting "rainbows" to make the pairings.
%C A252897 Number of perfect matchings in the graph with vertices 1 to 2n and edges {i,j} where i+j is a square. - _Robert Israel_, Mar 22 2015
%H A252897 Martin Fuller, <a href="/A252897/b252897.txt">Table of n, a(n) for n = 0..42</a>
%H A252897 Gordon Hamilton, Kiran S. Kedlaya, and Henri Picciotto, <a href="https://web.archive.org/web/20231103095235/https://www.maa.org/sites/default/files/pdf/awards/college.math.j.46.4.264.pdf">Square-Sum Pair Partitions</a>, The College Mathematics Journal, Vol. 46, No. 4 (September 2015), pp. 264-269.
%e A252897 One of the solutions for n=13 consists of the following pairings of 1-26:
%e A252897   {1,15}, adding to 16;
%e A252897   {2,23}, {3,22}, {4,21}, {5,20}, {6,19}, {7,18}, {8,17}, {9,16}, {11,14}, {12, 13}, each adding to 25;
%e A252897   {10,26}, adding to 36;
%e A252897   {24,25}, adding to 49.
%e A252897 There are five other such pairings possible, so a(13) = 6.
%p A252897 F:= proc(S)
%p A252897   option remember;
%p A252897   local s, ts;
%p A252897   if nops(S) = 0 then return 1 fi;
%p A252897   s:= S[-1];
%p A252897   ts:= select(t -> issqr(s+t),S minus {s});
%p A252897   add(procname(S minus {s,t}), t = ts);
%p A252897 end proc:
%p A252897 seq(F({$1..2*n}), n = 0 .. 24); # _Robert Israel_, Mar 22 2015
%t A252897 F[S_] := F[S] = Module[{s, ts}, If[Length[S] == 0, Return[1]]; s = S[[-1]]; ts = Select[S ~Complement~ {s}, IntegerQ[Sqrt[s + #]]&]; Sum[F[S ~Complement~ {s, t}], {t, ts}]];
%t A252897 Table[Print[n]; F[Range[2 n]], {n, 0, 24}] (* _Jean-François Alcover_, Mar 19 2019, after _Robert Israel_ *)
%Y A252897 Cf. A253472, A278329, A278339.
%K A252897 nonn
%O A252897 0,14
%A A252897 _Gordon Hamilton_, Mar 22 2015
%E A252897 a(26)-a(30) from _Hiroaki Yamanouchi_, Mar 25 2015
%E A252897 a(31) from _Alois P. Heinz_, Nov 16 2016
%E A252897 a(32)-a(36) from Linus and _Joost VandeVondele_, Jun 07 2018
%E A252897 a(37)-a(39) from _Bert Dobbelaere_, Aug 09 2022