Difference between Math.random()*5+1 and 6


#1

I just wanted to know what is the difference between
Math.floor(Math.random()*5+1)
and
Math.floor(Math.random()*6)


#2

With an offset of 1, the number range is shifted one to the right.

() * 5 + 1  =>  1..6

() * 6      =>  0..5

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.