Skip to main content

lcm

Function lcm 

Source
pub fn lcm(left: u64, right: u64) -> u64
Expand description

Computes the least common multiple of two unsigned integers.

lcm(a, 0) returns 0.

§Panics

Panics when the exact least common multiple does not fit in u64.

§Examples

use use_arithmetic::lcm;

assert_eq!(lcm(6, 15), 30);
assert_eq!(lcm(0, 15), 0);
Examples found in repository?
examples/basic_usage.rs (line 8)
6fn main() {
7    assert_eq!(gcd(54, 24), 6);
8    assert_eq!(lcm(6, 15), 30);
9    assert!(is_divisible_by(84, 7));
10    assert!(is_even(12));
11    assert!(is_odd(7));
12    assert_eq!(div_floor(-7, 3), -3);
13    assert_eq!(mod_floor(-7, 3), 2);
14    assert_eq!(checked_add(u8::MAX, 1), None);
15    assert_eq!(saturating_add(u8::MAX, 1), u8::MAX);
16    assert_eq!(wrapping_mul(200_u8, 2), 144);
17}