Random Number Generator: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
m Added to Common Alg. category
Lionel (talk | contribs)
I got the code from a public-domain website and modified it so it took a seed and maximum.
Line 13:
 
== Pseudorandom number generators ==
 
=== Simple Number Generator ===
This is a simple number generator that generates integers based on a seed and a maximum. It requires that random_seed(with a initial value) is defined.
<source lang="c">
int random_seed=0;
int rand(int seed,int max)
{
int tmpmax=max+1;
random_seed = random_seed+seed * 1103515245 +12345;
return (unsigned int)(random_seed / 65536) % tmpmax;
}
</source>
 
=== Linear congruential generator ===