Skip to main content

total_stopping_time

Function total_stopping_time 

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

Returns the number of steps needed to reach 1.

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

ยงExamples

use use_collatz::total_stopping_time;

assert_eq!(total_stopping_time(1), Some(0));
assert_eq!(total_stopping_time(6), Some(8));
Examples found in repository?
examples/facade_collatz.rs (line 5)
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}