RosettaCodeData/Task/Linear-congruential-generator/Liberty-BASIC/linear-congruential-generat...

24 lines
387 B
Plaintext

'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