Skip to main content

max_value_in_trajectory

Function max_value_in_trajectory 

Source
pub fn max_value_in_trajectory(n: u64) -> Option<u64>
Expand description

Returns the largest value reached in the trajectory from n to 1.

Returns None when n == 0 or when a checked odd step overflows.

ยงExamples

use use_collatz::max_value_in_trajectory;

assert_eq!(max_value_in_trajectory(1), Some(1));
assert_eq!(max_value_in_trajectory(6), Some(16));
Examples found in repository?
examples/facade_collatz.rs (line 7)
3fn main() {
4    assert_eq!(collatz_sequence(6), Some(vec![6, 3, 10, 5, 16, 8, 4, 2, 1]));
5    assert_eq!(total_stopping_time(6), Some(8));
6    assert_eq!(parity_vector(1), Some(vec![]));
7    assert_eq!(use_math::collatz::max_value_in_trajectory(7), Some(52));
8
9    let summary = verify_range(1, 10);
10
11    assert_eq!(summary.max_total_stopping_time, Some((9, 19)));
12    assert_eq!(summary.max_trajectory_value, Some((7, 52)));
13}