pub const fn exhaustive_nonzero_rationals() -> ExhaustiveNonzeroRationals 
Expand description

Generates all nonzero Rationals.

The sequence is the same the sequence of positive Rationals, interleaved with its negative. See exhaustive_positive_rationals for details.

The output length is infinite. The absolute values of the numerators and denominators of the $n$th element are $O(n^\frac{\log \phi}{\log 2})$.

§Worst-case complexity per iteration

$T(i) = O(\log i \log\log i \log\log\log i)$

$M(i) = O(\log i \log\log i)$

where $T$ is time, $M$ is additional memory, and $n$ is the iteration number.

§Examples

use malachite_base::iterators::prefix_to_string;
use malachite_q::exhaustive::exhaustive_nonzero_rationals;

assert_eq!(
    prefix_to_string(exhaustive_nonzero_rationals(), 20),
    "[1, -1, 1/2, -1/2, 2, -2, 1/3, -1/3, 3/2, -3/2, 2/3, -2/3, 3, -3, 1/4, -1/4, 4/3, -4/3, \
    3/5, -3/5, ...]"
)