Class Integer


back
gcd: x  | n  m |
" euclids gcd algorithm "
n <- self. m <- x.
(n <= 0 or: [m <= 0]) ifTrue: [ ^ 1].
[ n = m ] whileFalse: [ n < m ifTrue: [ m <- m - n ] ifFalse: [ n <- n - m ]].
^ n