lua - Generating an integer divisible by 90 with math.random() -
is possible make math.random()
return numbers divisible 90?
function random_90(lower, upper) return math.random(math.ceil(lower/90), math.floor(upper/90))*90 end print(random_90(100, 1000))
remember call math.randomseed()
once before using math.random()
. , it's better call math.random()
several times before using real because in implementations, first few numbers may not random.
math.randomseed(os.time()) math.random(); math.random(); math.random();
Comments
Post a Comment