Created
January 29, 2020 15:01
-
-
Save motsu0/b57cc6ce4640bbd0c57a5b745332f276 to your computer and use it in GitHub Desktop.
generate ramdom integer between M and N
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomMN(m,n){ | |
const d = Math.max(m,n)-Math.min(m,n); | |
return Math.floor(Math.random()*(d+1)+Math.min(m,n)); | |
} | |
// randomMN(3,9) => 3~9(int) | |
// randomMN(-2,4) => -2~4(int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment