This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize
for the AI-speak, we are working on rewriting it!
The program’s map: every function and which calls which.
There’s no recorded run of this program yet.
Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.
[1]lines 1–26
# Generated by tools/algo/legacy.py from the corpus: do not edit.# TheAlgorithms' two gcds (maths.viv).# Element comparisons are routed through lib/algo/legacy/order.viv; nothing else changes.import algo.legacy.order
# from study/idioms/thealgorithms-python/maths.viv: greatest_common_divisor gcd_by_iterative#| greatest_common_divisor.py: gcd(a, b) = |b| if a == 0 else gcd(b % a, a).#| `%` takes the sign of the divisor, as Python's does, which the doctests with negatives rely on.defgreatest_common_divisor(a, b) {
if a ==0.0 {
returnabs(b)
}
returngreatest_common_divisor(b % a, a)
}
defgcd_by_iterative(x0, y0) {
x = x0
y = y0
while y !=0.0 {
r = x % y
x = y
y = r
}
returnabs(x)
}