{ Copyright (C) 1984 D.M. Fritz-Rohner, P.O. Box 9080, Akron, Ohio 44305 } program main ; { } { Name: PERIOD - Compute PERIOD. } { } { Version: 1.0/TURBO 2 Date: July 17, 1984 } { } { Purpose: } { } { Compute TURBO Random function period. } { } { Description: } { } { This routine illustrates performance of TURBO's } { Random function. The program prompts for a } { positive integer modulus and then performs re- } { peated trials to compute the length of represen- } { tative sequences using that modulus. } { } { Reference: } { } { Author: } { } { D. M. Fritz-Rohner } { Post Office Box 9080 } { Akron, Ohio 44305 } { } { TURBO Pascal (tm) Borland International } { } var i, j, k, m, n : integer ; s : real ; begin { Prompt for Modulus } repeat write('Modulus: ') ; readln(n) until n > 0 ; { Initialize } Randomize ; { Show Header } writeln ; writeln(' Trial ','Initial',' Period') ; writeln ; { Perform Trials } for i := 1 to 16 do begin { Compute Initial Number } m := Random(n) ; { Search for Repeat } j := 0 ; k := 0 ; repeat if j = 32767 then begin k := k + 1 ; j := 0 end else j := j + 1 until m = Random(n) ; { Show Results } s := k * 32768. + j ; writeln(' ',i:3,' ',m:5,' ',s:6:0) end end. { Copyright (C) 1984 D.M. Fritz-Rohner, P.O. Box 9080, Akron, Ohio 44305 }