>>11052161>For all 0<=x<=sqrt(n)first of all, it should be sqrt(n/2)
worst case scenario, x and y are equal, you have:
x^2 + x^2 = n
x^2 = n/2
x = sqrt(n/2)
second of all: there are more squares from 0 to n/2 than there are from n/2 to n
they are more dense close to zero, so you should check the second half of the numbers, not the first
let's find solutions for 76 as an example, or show that there are no solutions
using your method:
is 76 square? no
76-1? no
76-4? no
76-9? no
76-16? no
76-25? no
76-36? no
that's 7 numbers to check
my method:
is 76 square? no
76-64? no
76-49? no
that's 3 numbers to check