Created
April 14, 2017 07:23
-
-
Save nyawach/30e1a294bc458ee06c24131c6fbe0b0a to your computer and use it in GitHub Desktop.
divideで割り切れる[min, max]のランダムな数を取得
This file contains hidden or 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 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