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

24 lines
387 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
'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