# How many ordered $2$ tuples can be chosen from $(1,2,..n)$ such that their sum is a perfect square?

How many ordered $2$ tuples can be chosen from $(1,2,..n)$ such that the sum of the two numbers within the tuple is a perfect square?

Will generating functions help here?

• You can arrange the ordered 2-tuples into a square array. The 2-tuples with constant sum appear along diagonals. So for squares in $[0,n]$ the sequence of counts of 2-tuples increases, then for squares in $[n,2n]$, the sequence of counts of 2-tuples decreases. Is there something about this that is blocking your progress? – Eric Towers Apr 16 '16 at 8:30