Skip to content

Instantly share code, notes, and snippets.

@Kasahs
Created September 26, 2018 12:20
Show Gist options
  • Save Kasahs/8b628fb9367e1672e9cbd2d89f174708 to your computer and use it in GitHub Desktop.
Save Kasahs/8b628fb9367e1672e9cbd2d89f174708 to your computer and use it in GitHub Desktop.
check if a number belongs to an AP described by first, last term and the diff
const belongsToAP = (first, diff, last) => {
return num => {
if (num < first || num > last) {
return false
}
const res = (num - first) / diff + 1
if (Number.isInteger(res)) {
return true
}
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment