interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / square-root / .meta / example.om

18 lines · 476 bytes Raw Blame History
1note Exercism-style exercise "square-root": https://exercism.org/tracks/python/exercises/square-root
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note squareroot is the integer square root of n: the largest r with r * r <= n.
4note Check it with: sh exercise.sh exercises/square-root
5om2
6fn squareroot n ulong to ulong
7lo = ulong 0
8hi = add div n 2 1
9while lt lo hi bound 64
10m = div add add lo hi 1 2
11if le m div n m
12lo = m
13else
14hi = sub m 1
15end
16end
17ret lo
18end