Skip to content

Instantly share code, notes, and snippets.

@motsu0
Created January 29, 2020 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motsu0/b57cc6ce4640bbd0c57a5b745332f276 to your computer and use it in GitHub Desktop.
Save motsu0/b57cc6ce4640bbd0c57a5b745332f276 to your computer and use it in GitHub Desktop.
generate ramdom integer between M and N
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