Skip to content

Instantly share code, notes, and snippets.

@seemcat
Created January 9, 2019 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seemcat/f2e923ffb1886dd0c78d8c0a0f1cbefa to your computer and use it in GitHub Desktop.
Save seemcat/f2e923ffb1886dd0c78d8c0a0f1cbefa to your computer and use it in GitHub Desktop.
c0d3 solved in JS
const solution = (num1, num2, common = [], i = 2) => {
if (num1 % i === 0 && num2 % i === 0) common.push(i);
if (i === num1 || i === num2) return Math.max(...common);
return solution(num1, num2, common, i + 1);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment