Random Number Generator
A Linear Congruential Random Number Generator (see Numerical Recipies in C by Press, Flannery, Teukolsky, Vetterling, section 7.1. for more information, or just check this link). It goes like this:
S[j] = (A * S[j - 1] + C) modulo M) R = N * S[j] / MWhere A (multiplier), C (increment), and M (modules) are appropriately chosen integral constants. S[j] is integral seed which is calculated from the previous seed (S[j-1]). R is the random double-precision floating point number calculated from the seed and normalized to the interval [N,0].
Each program is implemented using symbolic constants for A, C and M. The constants should be:
A = 3877 C = 29574 M = 139968For an input argument of 1000, the last random number generated should be 8.163294467 (starting with a seed value of 42).
The test exercises the ability of every language with a pure numerical algorithm, using both integers and floating point operations.
Input argument meaning
The argument specifies the number of random numbers to generate.
Last updated: Sun Jan 18 11:15:31 CET 2004