Expand description
Algorithms to generate smooth numbers.
See the definition of smooth number on Wikipedia and MathWorld.
§Examples
Generate the first 10 3-smooth numbers, i.e. numbers of the form 2^i * 3^j:
use smooth_numbers::smooth;
assert_eq!(smooth(3, 10), [1, 2, 3, 4, 6, 8, 9, 12, 16, 18]);Generate the first 10 5-smooth numbers, i.e. numbers of the form 2^i * 3^j * 5^k:
use smooth_numbers::smooth;
assert_eq!(smooth(5, 10), [1, 2, 3, 4, 5, 6, 8, 9, 10, 12]);Generate the first 10 numbers of the form 2^i * 5^j:
use smooth_numbers::with_primes;
assert_eq!(with_primes(&[2, 5], 10), [1, 2, 4, 5, 8, 10, 16, 20, 25, 32]);Functions§
- pratt
- Generates the first
nnumbers in the Pratt’s sequence. - smooth
- Generates the first
nk-smooth numbers, i.e. numbers whose prime factors are smaller than or equal tok. - with_
primes - Generates the first
nsmooth numbers whose prime factors are amongprimes.