Implementation of Algorithm 1.6 - Ulam's algorithm.
Author: Ryan McIntyre

Input is any natural number, n.

Output is number of iterations of before the sequence of n's 
ends in "4,2,1".

Optional 2nd input, limit, is the maximum number of iterations 
for which it will print the generated sequence, as opposed to 
just the number of iterations.