http://www.perlmonks.org?node_id=487289


in reply to Spiraling integers

In English (you said "in any language"):
  1. On a piece of paper, draw a square with sides equal to n.
  2. Divide the square into n x n equal little squares (call these "cells")
  3. Starting at the leftmost cell in the top row, write in it the figure 1
  4. In the empty cell to the right of the cell you just wrote into, write the value you just wrote plus 1; if there is no empty cell to the right, change your direction of movement to downwards.
  5. Keep moving in the same direction and writing down a number, equal to the one last written plus 1; if there is no empty cell in the direction you were moving, change direction as follows:
    • If you were moving to the right, change to downwards
    • If you were moving downwards, change to left
    • If you were moving to the left, change to upwards
    • If you were moving up, change to right
  6. Stop when the last number written is equal to n x n

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law