interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / collatz-conjecture / .meta / example.om

18 lines · 487 bytes Raw Blame History
1note Exercism-style exercise "collatz-conjecture": https://exercism.org/tracks/python/exercises/collatz-conjecture
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note Return how many steps n takes to reach 1 (n even: n / 2, n odd: 3n + 1). steps 1 is 0.
4note Check it with: sh exercise.sh exercises/collatz-conjecture
5om2
6fn steps n ulong to ulong
7v = n
8c = ulong 0
9while ne v 1 bound 999999
10if eq rem v 2 0
11v = div v 2
12else
13v = add mul v 3 1
14end
15c = add c 1
16end
17ret c
18end