Linear congruential generator: Difference between revisions

Content added Content deleted
No edit summary
Line 112: Line 112:
10450
10450
30612</pre>
30612</pre>

=={{header|bc}}==
{{trans|dc}}

{{works with|GNU bc}}

As with dc, bc has no bitwise operators.
<lang bc>/* BSD rand */

define rand() {
randseed = (randseed * 1103515245 + 12345) % 2147483648
return randseed
}

randseed = 1
rand(); rand(); rand(); print "\n"

/* Microsoft rand */

define rand() {
randseed = (randseed * 214013 + 2531011) % 2147483648
return randseed / 65536
}

randseed = 1
rand(); rand(); rand(); print "\n"</lang>


=={{header|C}}==
=={{header|C}}==