Some solutions for the julia path

This commit is contained in:
2025-08-04 19:44:03 +02:00
parent 5c52e8e34d
commit 8296c79f68
104 changed files with 4373 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
function is_even(n::Int)
return n % 2 == 0
end
function is_odd(n::Int)
return n % 2 != 0
end
function collatz_steps(n::Int)
if n <= 0
throw(DomainError("Input must be a positive integer."))
end
steps = 0
while n != 1
if is_even(n)
n ÷= 2
else
n = 3 * n + 1
end
steps += 1
end
return steps
end