Jump to content

Linear congruential generator: Difference between revisions

no edit summary
(In the task description, add the range of BSD and Microsoft rand_n, attempting to prohibit solutions like the F# code that yields numbers out of range.)
No edit summary
Line 283:
rand_ms 10
38 7719 21238 2437 8855 11797 8365 32285 10450 30612</lang>
 
=={{header|Liberty BASIC}}==
<lang lb>
'by default these are 0
global BSDState
global MSState
 
for i = 1 to 10
print randBSD()
next i
 
print
 
for i = 1 to 10
print randMS()
next i
 
function randBSD()
randBSD = (1103515245 * BSDState + 12345) mod (2 ^ 31)
BSDState = randBSD
end function
 
function randMS()
MSState = (214013 * MSState + 2531011) mod (2 ^ 31)
randMS = int(MSState / 2 ^ 16)
end function
</lang>
 
=={{header|PARI/GP}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.