begin
        comment
                321.a60:                        oct '90
                Erik Schoenfelder

                This is the
                        0. Start with a natural number n.
                        1. If n is odd, set n to be 3 * n + 1
                           If n is even, set n to be n / 2
                           Repeat step 1 until n is equal 1.
                        2. Print the number of repetitons.
                fun.
                And: Who knows, if this termimates for any n...
        ;

        integer procedure doit (n);
        value n;
        integer n;
        begin
                Boolean procedure odd (x);
                        value x; integer x;
                        odd := n != (n % 2) * 2;

                integer count;

                count := 0;
        d o:
                if odd (n) then
                        n := 3 * n + 1
                else
                        n := n % 2;

                count := count + 1;

                if n != 1 then go to d o;

                doit := count;
        end;


        integer i, n, val, max, NN;

        NN := 12;

        outstring (1, "Hi!\nn iterations\n");
        for i := 1 step 1 until NN do
                begin
                        outinteger(1, i);
                        outinteger(1, doit (i));
                        outstring (1, "\n")
                end;
        outstring (1, "...");

        outstring (1, "\nnow looking for maxima:");
        outstring (1, "\nn iterations\n");

        n := 0;  max := -1;
        for i := 1 step 1 until NN do begin
        d o:
                n := n + 1;
                val := doit (n);
                if val <= max then go to d o;

                outinteger (1, n);
                outinteger (1, val);
                outstring (1, "\n");
                max := val;
        end;
        outstring (1, "...\ndone.")
end
