ํ•ด๋‹ต

/// `n`์—์„œ ์‹œ์ž‘ํ•˜๋Š” ์ฝœ๋ผ์ธ  ์ˆ˜์—ด์˜ ๊ธธ์ด๋ฅผ ๊ฒฐ์ •ํ•ฉ๋‹ˆ๋‹ค.
fn collatz_length(mut n: i32) -> u32 {
    let mut len = 1;
    while n > 1 {
        n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 };
        len += 1;
    }
    len
}

#[test]
fn test_collatz_length() {
    assert_eq!(collatz_length(11), 15);
}

fn main() {
    println!("๊ธธ์ด: {}", collatz_length(11));
}