Permalink: http://bit.ly/R5rizQ
A function that can randomly pick an integer from a given range
can be used by applications that need a number dice roll and
random generation of strings, numbers, and
even random generation of complex passwords. Let's
say you would like to randomly pick a number from 1 to 10. This
gives us 10 choices to randomly pick, not 9 as can be mistakenly
thought of since 10 minus 1 equals 9. The same is with the range
of choices from 0 to 10. This gives 11 possibilities, not 10. To
illustrate:
- The range of choices should include the value of the lower end of the range
- It should …