[][src]Function reikna::factor::gcd_all

pub fn gcd_all(set: &[u64]) -> u64

Return the GCD of the set of integers

This function works by applying the fact that the GCD is both commutative and associative, and as such the GCD of a set can be found by computing the GCD of each of its members with a running GCD total.

If an empty set is given, 0 will be returned.

Examples

use reikna::factor::gcd_all;
assert_eq!(gcd_all(&vec![16, 4, 32]), 4);
assert_eq!(gcd_all(&vec![3, 10, 18]), 1);