--
-- This is a test of nested recursive parameterless procedure
-- calls with no local variables and forward declarations.
--
package test16 is body
    i, j, answer : integer;
    procedure factorial() is
	procedure times();
	procedure fact() is begin
	    times();  -- computes "answer := answer * j;"
	    if j <> i then j := j + 1; fact(); end if;
	end;
	procedure times() is begin answer := answer * j; end;
    begin
	answer := 1;
	j := 1;
	fact();
    end;
begin 
    write ("The first 5 factorials are (in descending order):");
    i := 5;
    loop
	exit when i <= 0;
        factorial();
        write("factorial(", i, ") = ", answer);
	i := i - 1;
    end loop;
end.
