in reply to Spiraling integers
In English ( you said "in any language"): - On a piece of paper, draw a square with sides equal to n.
- Divide the square into n x n equal little squares (call these "cells")
- Starting at the leftmost cell in the top row, write in it the figure 1
- 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.
- 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
- 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
|