Created
September 26, 2018 12:20
-
-
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
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
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