Skip to main content

stopping_time

Function stopping_time 

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

Returns the number of steps needed to first reach a value smaller than n.

Returns Some(0) for n == 1.

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

ยงExamples

use use_collatz::stopping_time;

assert_eq!(stopping_time(1), Some(0));
assert_eq!(stopping_time(6), Some(1));
assert_eq!(stopping_time(3), Some(6));