Created
January 28, 2018 12:31
-
-
Save vadimkorr/054d0a507e2ee465a260407aabee42c5 to your computer and use it in GitHub Desktop.
FInd numbers divisible by M
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
// Find numbers divisible by M in range A <= X <= B | |
let find = (a, b, m) => { | |
a = a%m == 0 ? a : a + m - a%m | |
while(a<=b) { | |
console.log(a); | |
a += m | |
} | |
console.log("===") | |
} | |
find(10, 21, 5) // 10, 15, 20 | |
find(11, 21, 5) // 15, 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment