Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function gcd(a, b) {
- if (a < 0 || b < 0) throw new Error('only positive nubmers');
- while (b > 0) {
- a %= b;
- b = [a, a = b][0];
- }
- return a;
- }
- console.log(gcd(15, 10));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement