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));