Skip to main content

verify_range

Function verify_range 

Source
pub fn verify_range(start: u64, end: u64) -> CollatzRangeSummary
Expand description

Verifies the inclusive range [start, end] with bounded Collatz exploration.

The function skips 0, counts the number of positive inputs checked, counts how many trajectories reach 1, counts how many overflow during checked odd steps, tracks the input with the largest total stopping time, and tracks the input with the largest peak trajectory value.

When start > end, the returned summary is empty and no values are checked.

ยงExamples

use use_collatz::verify_range;

let summary = verify_range(1, 10);

assert_eq!(summary.checked, 10);
assert_eq!(summary.reached_one, 10);
assert_eq!(summary.overflowed, 0);
assert_eq!(summary.max_total_stopping_time, Some((9, 19)));
assert_eq!(summary.max_trajectory_value, Some((7, 52)));
Examples found in repository?
examples/facade_collatz.rs (line 9)
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}