Here's an approach without `If` or `For`. First a helper function: (* Thanks to Belisarius for the mrow& suggestion *) g[x_] := NestWhile[mrow&, x, MemberQ[x - #, 0] &] Then: NestList[g, mrow, 9] // MatrixPlot Where `mrow` is as you've defined it in the question. ![Mathematica graphics](https://i.sstatic.net/4kJhl.png)