Count of (x,y) pairs that satisfy the equation x^2+y^2 = n^2
Your approach is to try every possible $x$ and&nbsp;$y$ and see if $x^2+y^2=n^2$. However, $n$&nbsp;is fixed and, for any&nbsp;$x$, either $n^2-x^2$ is a perfect square or it isn't. You can calculate what $y$&nbsp;is, instead of looping and trying every possible value.

Actual code is off-topic but it's confusing that you're trying to solve a problem about $x$ and&nbsp;$y$, but you've represented those quantities in variables called i and&nbsp;j. And even worse that you have a variable called&nbsp;x that represents something else entirely. (In fact, I'm not sure it's even correct. You seem to be using&nbsp;x to avoid reporting, e.g., $x=3$, $y=4$ and $x=4$, $y=3$ as separate solutions for $n=5$. But they are separate solutions and the question, at least as you've summarized it, doesn't say that they should be counted as the same.)