Algorithm Implementation/Pseudorandom Numbers/Linear congruential generator

#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;
}