We can access matrices using linear indexing, which follows this pattern
0 1 2
3 4 5
6 7 8
It\'s easy to get the i,j coordinates for this cas
For 0-index based:
int j = 0; int x = (n-1); while (idx > x) { j++; idx=idx-x; x--; } i=idx;