Xref: utzoo comp.sys.mac:55950 comp.sys.mac.programmer:15718 comp.sys.mac.misc:1006 comp.sys.mac.system:698 Path: 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 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