[Edit]
+
0
-
0
LCG (Linear Congruential Generator) - algorithm parameters (M, A, C)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57+=======================================================================================+======================+======================+=======================+ | Source | modulus (m) | multiplier (a) | increment (c) | +=======================================================================================+======================+======================+=======================+ +=======================================================================================+======================+======================+=======================+ | ZX81 | 65537 | 75 | 74 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | Numerical Recipes from the "quick and dirty generators" list, Chapter 7.1, Eq. 7.1.6 | | | | | parameters from Knuth and H. W. Lewis | 4294967296 | 1664525 | 1013904223 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | Borland C/C++ | 4294967296 | 22695477 | 1 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | glibc (used by GCC) | 2147483648 | 1103515245 | 12345 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | ANSI C: Watcom, Digital Mars, CodeWarrior, IBM VisualAge C/C++ | | | | | C90, C99, C11: Suggestion in the ISO/IEC 9899, C17 | 2147483648 | 1103515245 | 12345 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | Borland Delphi, Virtual Pascal | 4294967296 | 134775813 | 1 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | Turbo Pascal | 4294967296 | 134775813 | 1 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | Microsoft Visual/Quick C/C++ | 4294967296 | 214013 | 2531011 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | Microsoft Visual Basic (6 and earlier) | 16777216 | 1140671485 | 12820163 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | RtlUniform from Native API | 2147483647 | 2147483629 | 2147483587 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | Apple CarbonLib, C++11's minstd_rand0, | | | | | MATLAB's v4 legacy generator mcg16807 | 2147483647 | 16807 | 0 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | C++11's minstd_rand | 2147483647 | 48271 | 0 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | MMIX by Donald Knuth | 18446744073709551616 | 6364136223846793005 | 1442695040888963407 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | Newlib, Musl | 18446744073709551616 | 6364136223846793005 | 1 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | VMS's MTH$RANDOM, old versions of glibc | 4294967296 | 69069 | 1 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | Java's java.util.Random, POSIX [ln]rand48, glibc [ln]rand48[_r] | 281474976710656 | 25214903917 | 11 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | random0 | 134456 | 8121 | 28411 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | POSIX [jm]rand48, glibc [mj]rand48[_r] | 281474976710656 | 25214903917 | 11 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | POSIX [de]rand48, glibc [de]rand48[_r] | 281474976710656 | 25214903917 | 11 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | cc65 | 8388608 | 65793 | 4282663 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | cc65 | 4294967296 | 16843009 | 826366247 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | cc65 | 4294967296 | 16843009 | 3014898611 | +---------------------------------------------------------------------------------------+----------------------+----------------------+-----------------------+ | Formerly common: RANDU | 2147483648 | 65539 | 0 | +=======================================================================================+======================+======================+=======================+ See also: 1. LCG algorithm implementation in JavaScript: https://dirask.com/posts/JavaScript-own-random-number-generator-custom-implementation-9pYYRp