Algorith/ Equation to get the ith element in N x N I am having a difficulty figuring out the equation to get the ith element in $\mathbb{N}\times \mathbb{N}$ ( crossing the set of natural numbers).We have $\mathbb{N}\times \mathbb{N} = \{ (1,1),(1,2),(2,1),(1,3),(2,2)\dots\}$ if we traverse the matrix with a diagonal.Can someone help me in getting this equation ?
I want to do a small program that takes index $i$ , and return the $i$th element in $\mathbb{N}\times\mathbb{N}$.This will be used for demonstration

I believe I got your question and you can find several solutions here:
https://stackoverflow.com/questions/1779199/traverse-matrix-in-diagonal-strips
