all_factors_of

Function all_factors_of 

Source
pub fn all_factors_of(x: u64) -> Vec<u64>
Expand description

Retrieves every factor of x

This function is only available with the factors feature enabled.

A factor is any number that divides x. Therefore, it includes 1 and x itself.

This function is simply an abstraction over creating the Factorization struct and calling Factorization::all_factors.

Note: The returned vector will have length 1, if and only if x is 1. It will have length 2 if and only if x is prime. However, it’s much faster to verify if a number is prime using PrimeData.

§Examples

use prime_data::all_factors_of;
 
assert_eq!(all_factors_of(1), vec![1]);
assert_eq!(all_factors_of(3), vec![1, 3]);
assert_eq!(all_factors_of(6), vec![1, 2, 3, 6]);