Skip to content

Instantly share code, notes, and snippets.

@vadimkorr
Created January 28, 2018 12:31
Show Gist options
  • Save vadimkorr/054d0a507e2ee465a260407aabee42c5 to your computer and use it in GitHub Desktop.
Save vadimkorr/054d0a507e2ee465a260407aabee42c5 to your computer and use it in GitHub Desktop.
FInd numbers divisible by M
// 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