BSD libc default rand()

Usage

For random numbers generated using rand() from BSD.

Generator

Seed:

Seed Range

Unsigned Integer (32-bit)
Seed Size: 31 bits
Default Seed: 1

Definition

MCG
X0 = Seed
Xn+1 = 16807 Xn mod 2147483647 (Xn is replaced by 123459876 if it is 0)
Initial Output: X1
Output: X
Range: 1 ~ 2147483646

Sample Code for 100 Values (C):

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
	if (argc >= 2) {
		srand(atoi(argv[1]));
	}
	int i;
	for (i = 0; i < 100; ++i){
		printf("%d ", rand());
	};
	return 0;
}