Last active
April 6, 2023 16:09
-
-
Save aquaslvt/e4ae27147ea85990cbb3dc137ff7dfb3 to your computer and use it in GitHub Desktop.
Collatz conjecture in Lua
This file contains hidden or 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
local n = io.read("*n") | |
repeat | |
if n % 2 == 0 then | |
n = n / 2 | |
print(math.floor(n)) | |
else | |
n = n * 3 + 1 | |
print(math.floor(n)) | |
end | |
until n == 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
here's it in blaze it