411 REFERENCE · Wikibooks
Algorithm Implementation/Pseudorandom Numbers/Linear congruential generator
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
C
#define RAND_MAX 32768
static unsigned long int next = 1;
int lcg(void)
{
next = next * 1103515245 + 12345;
return (unsigned int) (next / 65536) % RAND_MAX;
}
void slcg(unsigned int seed)
{
next = seed;
}