Lately, I was participating in a job interview, that included programming assignments. One of the assignments was:  

White a function, that will find all integer values pairs `x`, `y` that for given integer `n` solve the equation:
`x^2 - 4y^2 = n`

My approach was:
I rewrote thes equation for `y`: `y = sqrt(x^2 - n) / 2`  

Made for loop from `x=sqrt(n)` to `x=n`  

For every `x` I computed `y` value and checked, if `y` is an integer. 

This solution gave corrected answers, however, for large `n` this algorithm did not meet performance criteria.  

In assignment there were also hint given, that: `x^2 - 4y^2 = (x - 2y)(x + 2y)`, but I have no idea how to use this hint for solving that problem.

Just for curiosity (as the assignment is now over), any ideas how to solve this problem in an optimal way?