Diagonal acces of a grid Element?

hey all,

i hope to find a math formula to acces grid MATRIX elements diagonaly!

so lets say i have a grid of mc:
(the numbers are the id’s)

10,12,13,14,15
16,17,18,19,20
21,22,23,24,25
26,27,28,29,30
31,32,33,34,35

so acces diagonaly from leftdown to rigthup i would have this:

10,16,12,21,17,13,26,22,18,14,31,27.23,19,15,32,28,24,20,33,29,25,34,30,35

HOW CAN I DO THIS? :frowning:

i need a formula when i decide to have a grid 100 x 100 it wil work to…

any help?