test: proc options (main); declare (longest, n) fixed (15); declare flag bit (1); declare (i, value) fixed (15); /* Task 1: */ flag = '1'b; put skip list ('The sequence for 27 is'); i = hailstones(27); /* Task 2: */ flag = '0'b; longest = 0; do i = 1 to 99999; if longest < hailstones(i) then do; longest = hailstones(i); value = i; end; end; put skip edit (value, ' has the longest sequence of ', longest) (a); hailstones: procedure (n) returns ( fixed (15)); declare n fixed (15) nonassignable; declare (m, p) fixed (15); m = n; p = 1; if flag then put skip list (m); do p = 1 by 1 while (m > 1); if iand(m, 1) = 0 then m = m/2; else m = 3*m + 1; if flag then put skip list (m); end; if flag then put skip list ('The hailstone sequence has length' || p); return (p); end hailstones; end test;