Skip to content

Instantly share code, notes, and snippets.

@j3ck
Created November 14, 2019 13:40
Show Gist options
  • Save j3ck/b890135b5ec5df0f1f87c6a8d6cb085c to your computer and use it in GitHub Desktop.
Save j3ck/b890135b5ec5df0f1f87c6a8d6cb085c to your computer and use it in GitHub Desktop.
const smallestDivisor = (num) => {
// BEGIN (write your solution here)
const div = (iter) => {
if (num === iter) {
return num;
}
if (iter > 1 && num % iter === 0) {
return iter;
}
return div(iter + 1);
};
return div(1);
// END
};
export default smallestDivisor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment