Skip to content

Instantly share code, notes, and snippets.

@okumurakengo
Created May 6, 2020 07:31
Show Gist options
  • Save okumurakengo/d2d4510fe47a700c2de3c9be49d22bb9 to your computer and use it in GitHub Desktop.
Save okumurakengo/d2d4510fe47a700c2de3c9be49d22bb9 to your computer and use it in GitHub Desktop.
ユークリッドの互除法
let a = 273
,b = 1001
function* foo() {
while (true) {
yield (a < b) ? [a, b - a] : [a - b, a]
}
}
for ([a, b] of foo(a, b)) {
console.log(a, b)
if (a === b) {
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment