GO版
var randomSeed = 5
func random() float64 {
randomSeed = (randomSeed*9301 + 49297) % 233280.0
v := float64(randomSeed) / (233280.0)
return v
}
func rand(min, max int64) int64 {
return int64(random()*float64(max-min+1)) + min
}
LUA版
local randomSeed = 5;
function random()
randomSeed = ( randomSeed * 9301 + 49297 ) % 233280.0;
return randomSeed / ( 233280.0 );
end
function rand(min, max)
return math.floor(random() * (max - min + 1) + min)
end
for i = 0, 10 do
print(rand(1, 100))
end
JS版本
var randomSeed = 5;
function random(){
randomSeed = ( randomSeed * 9301 + 49297 ) % 233280.0;
return randomSeed / ( 233280.0 );
};
for( var i = 0;i<100;i++ )
{
console.log("random:", random()*100 | 0);
}