Filling the gaps

Which numbers can we write as a sum of square numbers?

Problem

Filling the Gaps printable sheet

 

Charlie has been thinking about which numbers can be written as a sum of two square numbers.  He took a $10\times10$ grid, and shaded the square numbers in blue and the sums of two squares in yellow.

Image
A grid with numbers from 1 to 100 in order, with 10 numbers in each row. Cells with square numbers are blue, numbers which are the sum of two squares have their cells yellow, and the remaining cells are white.

He hoped to find a pattern, but couldn't see anything obvious. 

Vicky suggested changing the number of columns in the grid, so they reduced it by one:

Image
A grid with numbers from 1 to 99 in order, with 9 numbers in each row. Cells with square numbers are blue, numbers which are the sum of two squares have their cells yellow, and the remaining cells are white.

"There seems to be a diagonal pattern."

"If the rows were one shorter, then those diagonals would line up into vertical columns, wouldn't they?"

"Let's try it..." 

Image
A grid with numbers from 1 to 96 in order, with 8 numbers in each row. Cells with square numbers are blue, numbers which are the sum of two squares have their cells yellow, and the remaining cells are white.

What do you notice about the positions of the square numbers?

What do you notice about the positions of the sums of two square numbers?

 

Can you make any conjectures about the columns in which squares, and sums of two squares, would appear if the grid continued beyond 96?

 

Can you prove any of your conjectures?

 

You might like to look back at the nine-column grid and ask yourself the same questions.

 

Charlie couldn't write every number as a sum of two squares.  He wondered what would happen if he allowed himself three squares.

Image
A grid with numbers from 1 to 96 in order, with 8 numbers in each row. Cells with square numbers are blue, numbers which are the sum of two squares have their cells yellow, numbers which are the sum of three squares are in green cells, and the remaining cells are white.

 

Will any of the numbers in the seventh column be a sum of three squares?

Can you prove it?

"We must be able to write every number if we are allowed to include sums of four squares!"

"Yes, but it's not easy to prove.  Several great mathematicians worked on it over a long period before Lagrange gave the first proof in 1770."

With thanks to Vicky Neale who created this task in collaboration with NRICH.