🟩➕🟦

Square Sum

Week 36

There are many noteworthy things about the number 36 - like the fact it is highly factorisable and a triangular number. Your friend also claims its a relatively unique number, in that it can be made by adding many different combinations of square numbers together - you want to test your friend's theory to find out just how unique (or not) 36 is in this regard

For example, 36 can be made by summing the following square numbers:

Your program should output all square number combinations that sum to every number from 1 to 100 (in ascending order) - a few rules:

  • We will ignore 0 (i.e. 0 * 0) and 1 (i.e. 1 * 1) as square numbers - since otherwise you can trivially do 1 + 1 + 1...to create all positive integers, infinitely add 0s, add 0 to get a sum of more than 1 term. 4 (i.e. 2 * 2) should hence be the smallest square
  • Each combination should be unique and the terms should be displayed in ascending order - e.g. 4 + 4 + 16 is VALID, but any other order like 4 + 16 + 4 or 16 + 4 + 4 is NOT valid - this prevents having huge numbers of equivalent combinations for larger numbers and the ordered sequence is easier to visualise/understand for any end user
  • A sequence should consist of at least 2 numbers added together - i.e. 9 = 9 (3*3) is invalid, since that sum only consists of one square. In other words, the square number itself should not be valid - e.g. 4 = 4, 9 = 9, 16 = 16 etc
  • If a number has no square sum, then it shouldn't be output - for example, there is no way to make 1, 2, 3, 4, 5, 7, 9...etc by summing two square numbers, hence they shouldn't be output

As a hint, here are the first 3 lines of the valid output - for numbers with multiple solutions (like the 4 solutions for 36 above), the order of those solutions doesn't matter (e.g. you could put the 36 = 9 + 9 + 9 + 9 solution before the 36 = 4 + 4 + 4...+4 solution), since the site will order the lines, remove spaces etc when you click submit)

Paste your answer below:

Hints

Hints will be released at the start of each of the following days - e.g. the start of day 3 is 48 hours after the challenge starts

Release Day Hint
2
36 2026