How to find X,Y coordinates on this?

Given this square-spiral pattern of numbers:

7 6 5

8 1 4

9 2 3

10 11 12...

Is it possible to create a equation that will give me an X,Y coordinate, with 1 being 0,0, if I have a number (N)?

I figured out an algorithm (of sorts) using the knowledge that evens^2(from 2 up)+1 give a diagonal line upright and odds^2 (from 1 up)+0 give a diagonal line down and that the side length is sqrt(next corner>N [as defined above])-1. This is quite slow and inefficient, hence the hope for some sort of equation or simpler logic to find the coordinates.

Thanks in advanced :), and I hope this is the appropriate area to post this question.