Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix math.lcm, broken for every input
$B.$getattr(product, '__floordiv__') on a JS number is not callable; use
$B.rich_op which handles both small ints and long ints.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
  • Loading branch information
zalo and claude committed Aug 13, 2026
commit 7ccbaa7e87272ce0372f8d22f30e688e6dfd98e4
4 changes: 3 additions & 1 deletion www/src/libs/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,9 @@ function lcm() {
}
gcd = gcd2(a, b)
product = $B.rich_op('__mul__', a, b)
a = $B.$getattr(product, "__floordiv__")(gcd)
// product may be a JS number (Brython small int) or a long_int:
// use rich_op, which handles both, instead of getattr on the value
a = $B.rich_op('__floordiv__', product, gcd)
}
return a
}
Expand Down