Skip to content

Instantly share code, notes, and snippets.

@nyawach
Created April 14, 2017 07:23
Show Gist options
  • Save nyawach/30e1a294bc458ee06c24131c6fbe0b0a to your computer and use it in GitHub Desktop.
Save nyawach/30e1a294bc458ee06c24131c6fbe0b0a to your computer and use it in GitHub Desktop.
divideで割り切れる[min, max]のランダムな数を取得
function getRandomFlattenNum(min, max, divide) {
let n = Math.random() * (max - min) + min;
n = flattenNum(n, divide);
return n;
}
function flattenNum(n, d) {
return n = n - (n % d);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment