pub fn parity_vector(n: u64) -> Option<Vec<CollatzParity>>Expand description
Returns the parity pattern for the trajectory from n to 1.
The returned vector includes the starting value and every nonterminal value
in the trajectory, but it excludes the final 1. For n == 1, this means
the parity vector is empty.
Returns None when n == 0 or when a checked odd step overflows.
ยงExamples
use use_collatz::{CollatzParity, parity_vector};
assert_eq!(
parity_vector(6),
Some(vec![
CollatzParity::Even,
CollatzParity::Odd,
CollatzParity::Even,
CollatzParity::Odd,
CollatzParity::Even,
CollatzParity::Even,
CollatzParity::Even,
CollatzParity::Even,
])
);
assert_eq!(parity_vector(1), Some(vec![]));