Skip to content

Instantly share code, notes, and snippets.

@aquaslvt
Last active April 6, 2023 16:09
Show Gist options
  • Save aquaslvt/e4ae27147ea85990cbb3dc137ff7dfb3 to your computer and use it in GitHub Desktop.
Save aquaslvt/e4ae27147ea85990cbb3dc137ff7dfb3 to your computer and use it in GitHub Desktop.
Collatz conjecture in Lua
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
@T-8492
Copy link

T-8492 commented Apr 6, 2023

here's it in blaze it

get "blazeit"
get "statements"
get "math"

n is -blaze in, number

while n is ≠1
if modulo(n,2) is =0 then
change n to divide(n,2)
blaze it floor(n)
else
change n to add(multiply(n,3),1) << nested stuff >>
blaze it floor(n)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment