-- THIS TEST RETURNS A  A RANDOM INTEGER RESULT SUCH THAT (LOWER <= RESU
with Instrument;
use Instrument;
procedure Randa2 is
    Cycle : constant Integer := 10000;
    subtype Seed is Integer;
    Prev : Seed := 3657;
    subtype Random is Integer;
    subtype Bound is Random;
    L : Bound := 0;
    U : Bound := 1000;
    P : Seed := Prev;
    R : Random;


    procedure Rand (Lower : in Bound := 0;    --LOWER BOUND
                    Upper : in Bound := 10;    --UPPER BOUND
                    Prev : in out Seed;   --VALUE USED TO COMPUTE NEXT ONE
                    Result : out Random) is
        A : Integer := 3;
        M : Integer := 2#1111111111011#;

    begin
        Prev := (A * Prev) mod M;
        Result := (Prev mod (Upper - Lower + 1)) + Lower;
    end Rand;

begin
    Start ("RANDA2", " RANDOM NUMBER GENERATOR");
    for I in 1 .. Cycle loop
        Rand (L, U, P, R);
    end loop;
    Stop;
end Randa2;