🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #12958

Re: Random number Generator wanted.

#12958
From: Michael Nolan
Date: Tue, 03 Jul 1990 19:01
22 lines
1576 bytes
It's fairly easy to write a random number generator, and there are several
in Knuth's "Art of Computer Programming", I *think* in volume 2, at any rate
the subject matter of the correct volume is algorithms.
 
One I've used many times involves three relatively prime numbers n1, n2, and n3.
(Relatively prime means these numbers have no common factors above 1.)

Please pardon my pseudocode:

       This_Random_Number = (Previous_Random_Number * n1 + n2) mod n3.

Of course, you need to provide an initial Previous_Random_Number as a seed.  

This will generate a random number sequence of period n3.  I assume this will
work in longints.
------------------------------------------------------------------------------
Mike Nolan                                       "I don't know what apathy is,
Tailored Software Services, Inc.                  and I don't want to find out!"
Lincoln, Nebraska (402) 423-1490                
UUCP: tssi!nolan should work, 
      if not try something like uunet!frith!upba!tssi!nolan 
Technical Details
Message-ID: <1705@tssi.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tektronix!sequent!upba!tssi!nolan
References: <152@asacsg.mh.nl>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tektronix!sequent!upba!tssi!nolan
From: nolan@tssi.UUCP (Michael Nolan)
Newsgroups: comp.sys.mac,comp.sys.mac.programmer,comp.sys.mac.misc,comp.sys.mac.system
Subject: Re: Random number Generator wanted.
Summary: Try any of the algorithms in Knuth, sample given
Keywords: Random number
Message-ID: <1705@tssi.UUCP>
Date: 3 Jul 90 19:01:14 GMT
References: <152@asacsg.mh.nl>
Organization: Tailored Software Svcs, Lincoln Neb
Lines: 22