Crate smooth_numbers

source ·
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

  • Generates the first n numbers in the Pratt’s sequence.
  • Generates the first n k-smooth numbers, i.e. numbers whose prime factors are smaller than or equal to k.
  • Generates the first n smooth numbers whose prime factors are among primes.