# WRONG, DO NOT USE use warnings; use strict; sub divmod { my($a, $m) = @_; my($b, $x, $y, $n) = ($m, 1, 0); while (0 != $a) { $n = int($b / $a); ($a, $b, $x, $y) = ($b - $n * $a, $a, $y - $n * $x, $x); } $y % $m; }