Hi,

If I have a triangle like this:

1 2 4 7 11 16

3 5 8 12 17

6 9 13

10 14

15

... which goes on to contain $\displaystyle $n$$ numbers (although I don't think the size is relavent).

Notice the way it's ordered. The numbers can be considered as the ordinal index of a node of the triangle. The numbers are ordered going diagonally from top right to bottom left, and creating a new diagonal line which is longer as you go right.

The problem is, given a node with ordinal index $\displaystyle $q$$, how can I find what the $\displaystyle $x$$ and $\displaystyle $y$$ coordinate is of $\displaystyle $q$$? Is there a formula?

For example:

get_x_index(13) = 2

get_y_index(13) = 2

get_x_index(17) = 4

get_y_index(17) = 1

Does anyone know how to do this?

Thanks.