1291025…4381124…5671223…1615141322…1718192021…⋮⋮⋮⋮⋮
Let f(y,x) represent the number in row y and column x.
f(1,x)={x2 if x is odd,(x−1)2+1 if x is even.
f(y,1)={y2 if y is even,(y−1)2+1 if y is odd.
(y,x) falls exactly on the diagonal if and only if y=x.
(y,x) falls above/on the right of diagonal if and only if y<x.
(y,x) falls below/on the left of the diagonal if and only if y>x.
f(y,x)={f(1,x)−(y−1) if y≤x and x is odd,f(1,x)+(y−1) if y≤x and x is even,f(y,1)+(x−1) if y≥x and x is odd,f(y,1)−(x−1) if y≥x and x is even.