Given the sequence OEIS A033581, which is the infinite sequence, the n'th term (0-indexing) is given by the closed form formula 6 × n2 .
Your task is to write code, which outputs all the subsets of the set of N first numbers in the sequence, such that the sum of the subset is a perfect square.
Rules
- The integer
N
is given as input. - You cannot reuse a number already used in the sum. (that is, each number can appear in each subset at most once)
- Numbers used can be non-consecutive.
- Code with the least size wins.
Example
The given sequence is {0,6,24,54,96,...,15000}
One of the required subsets will be {6,24,294}, because
6+24+294 = 324 = 18^2
You need to find all such sets of all possible lengths in the given range.