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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -