Show all ways 365 can be written as the sum of 2 or more different perfect square numbers?

183 Views Asked by At

I need help with this problem please explain all the appropriate steps.

3

There are 3 best solutions below

0
On

This program gives you all of the results.

1
On

A recursive program seems a reasonable approach. Write a routine that takes the target number which starts at $365$ here and a maximum square to use. If you don't supply it, it could compute the maximum, which here is $19$. It would try using $19$, compute $365-19^2=4$ and call itself to express $4$. When it ran out of ways to express $4$ it returns and the first instance tries to express $365$ with a maximum of $18^2$ and so on. You could save some time by caching the results for small numbers.

2
On
  • parity considerations show an odd number of them are odd.
  • mod 3, a 2 mod 3 number of them are 1 mod 3

looking at these mod 6

  • the number of 1,4 mod 6 is either 2 or 5 mod 6
  • the number of 1,3 mod 6 is in 1,3,5 mod 6

we also have

  • the number of 1 mod 6 is 2 mod 3 in 1,3 only scenario
  • the number of 1 mod 6 is 1 mod 3 in 1,4 only scenario.
  • the number of 1 mod 6 is 5 mod 6 in the 1 only scenario
  • the only 3 or only 4 scenarios can't work.
  • the number of 4 mod 6 is 2 mod 3 in the 3,4 only scenario
  • the number of 1,4 mod 6 is 2 mod 3 in the 1,3,4 scenario.

Finally we have that at least one of the squares stays below 182, leading to one of the bases being below 14.