Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718/// Determine the length of the collatz sequence beginning at `n`.fn collatz_length(mut n: u32) -> u32 { let mut count: u32 = 1;
loop { count += 1; n = if n % 2 == 0 { n / 2 } else { n * 3 + 1 };
if n == 1 { break; } } count}
fn main() { println!("Length: {}", collatz_length(2)); // should be 15}