home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / pascal / 6694 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  1014 b 

  1. Path: sparky!uunet!caen!uwm.edu!csd4.csd.uwm.edu!randyd
  2. From: randyd@csd4.csd.uwm.edu (Randall Elton Ding)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: Encryption and Random Numbers
  5. Date: 18 Nov 1992 19:53:28 GMT
  6. Organization: Computing Services Division, University of Wisconsin - Milwaukee
  7. Lines: 21
  8. Message-ID: <1ee6voINNilt@uwm.edu>
  9. References: <1992Nov17.211502.18511@lynx.dac.northeastern.edu> <1992Nov18.030335.15774@cc.umontreal.ca>
  10. NNTP-Posting-Host: 129.89.7.4
  11.  
  12. There has been some discussion about random number generators,
  13. here is a simple minded function that works pretty good for me.
  14. I believe it could be modified to produce random reals as well.
  15.  
  16. function new_random (m: word): word;
  17.   const
  18.     s1: integer = $1357;   { random seeds }
  19.     s2: integer = $2468;
  20.     s3: integer = $3579;
  21.     s4: integer = $468A;
  22.     s5: integer = $579B;
  23.   var result: word;
  24.   begin
  25.     result:= s1+s2+s3+s4+s5;
  26.     s5:= s4;
  27.     s4:= s3;
  28.     s3:= s2;
  29.     s2:= s1;
  30.     s1:= result;
  31.     new_random:= result mod m;
  32.   end;
  33.