#include <stdio.h>

int main()
{
    int n;  /* Number to step through */
    int steps;  /* Steps taken */
    int currn;  /* Current value of no in iterative process */

    /* Check it out for all values of n from 2 to 100 */
    for (n= 2; n < 100; n++) {
        currn= n;  /* currn is used for the iterative
                     process */
        steps= 0;

                  /* Repeat the loop until we've returned
                    to 1 */
        while (currn != 1) {
             /* Check for evenness */
            if (2*(currn/2) == currn)
                 currn/=2;    /* Even nos divided by 2 */
            else
                 currn= currn*3+1;
            steps++;  /* Count the no of steps we take */
        }
        printf ("%d takes %d steps to return to 1\n",n,
           steps);
    }
    return 0;
}

