Created
September 6, 2021 08:09
-
-
Save mandel59/e85224355f63d228992b7665099d0391 to your computer and use it in GitHub Desktop.
コラッツの数列を表示
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
let i = BigInt(Deno.args[0]); | |
while (true) { | |
if (i <= 0n) throw new RangeError(); | |
console.log(String(i)); | |
if (i === 1n) break; | |
if (i % 2n === 0n) { | |
i /= 2n; | |
} else { | |
i = i * 3n + 1n; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment