: next-iteration ( n -- m ) dup even? [ 2 / ] [ 3 * 1 + ] if ; : chain ( n -- count ) [ dup 1 = not ] [ next-iteration dup ] produce nip length ; ! ( scratchpad ) 4 chain . 2