marc, very nice! there's a ternary version too: write n in ternary, sort digits: e.g. 7 -> 21 -> 12 -> 5 giving 1 2 1 4 5 2 5 8 1 4 5 etc for n = 1 2 3 4 5 6 etc Neil