
PROGRAM TestSeqSearch (Input,Output);

CONST
   MaxSize = 5000;
   m = 100000000;     
   b = 31415821;
   m1 = 10000;

TYPE
   ArrayType = Array[1..MaxSize] of Integer;
   
VAR
   TestArray : ArrayType;
   j, SearchKey, Tests : Integer;
   RandNum : Integer4;
  




FUNCTION Mult (p, q :Integer4) : Integer4;
Var 
   p1 , p0, q1, q0 : Integer4;
Begin
   p1 := p DIV m1;
   p0 := p MOD m1;
   q1 := q DIV m1;
   q0 := q MOD m1;
   Mult := (((p0*q1 + p1*q0) MOD m1) * m1 + p0*q0) MOD m;
End;




{Generate a pseudo-random number between 0 and 1.
RandNum should be seeded at start of each program. }

FUNCTION Random : Real;

Begin
   RandNum := (Mult(RandNum,b) + 1) MOD m;
   Random := RandNum / m;
End;



{
FUNCTION Chisquare (N : Integer) : Real;
Const
   Rmax = 100;
Var
   i, j, t : Integer;
   f : Array[0..Rmax] of Integer;
   A : ArrayType; 
Begin
   Writeln('Seed');
   Readln(RandNum);
   FOR i := 0 to Rmax DO
      f[i] := 0;

   FOR i := 1 to N DO
    Begin
     t := Trunc (Random * Rmax);
     f[t] := f[t] + 1;
     A[i] := t;
    End;

   i := 1;
   REPEAT
      FOR j := 0 to 4 DO
         Write(A[i+j]);
      Writeln;
      i := i + 5;
   UNTIL i >= N;

   t := 0;
   FOR i := 0 to Rmax-1 DO
      t := t + f[i]*f[i];
   Chisquare := (Rmax*t / N) - N;
End;   
}


