[...] of N, the algorithm rotates the matrix after inserting the elements. I've previously shown that it is easy to write SAS/IML statements that rotate elements in a matrix. My algorithm constructs the spiral iteratively. Notice that if you have constructed the spiral …