Nice function to get a random number in C

Member

erica

by erica , in category: C/C++ , 2 months ago

Nice function to get a random number in C

1
2
3
4
5
6
7
8
void init_rand(unsigned long int x)
{
	int i;
	Q[0] = x;
	Q[1] = x + PHI;
	Q[2] = x + PHI + PHI;
	for (i = 3; i < 4096; i++){ Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i; }
}

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

no answers