gcd
fn gcd(int a, int b) -> int Import
Source: use num::{gcd}; src/num.hy Returns the greatest common divisor of a and b, which should be non-negative. gcd(0, 0) is 0.
Parameters#
| Name | Type |
|---|---|
a | int |
b | int |
Returns#
int
Examples#
use num::{gcd};
use tests::assert;
assert!(gcd(12, 18) == 6);
See also#
abs: Returns the absolute value ofx.min: Returns the smaller ofaandb(awhen they are equal).max: Returns the larger ofaandb(awhen they are equal).round: Roundsxto the nearest whole number; halves round away from zero.clamp: Returnsxlimited to the rangelo..=hi.signum: Returns-1,0or1by the sign ofx.lcm: Returns the least common multiple ofaandb, which should be non-negative;0when either is0.trunc: Removes the fractional part ofx, rounding toward zero.