while
๋ฐ๋ณต๋ฌธ
while
ํค์๋๋ ๋ค๋ฅธ ์ธ์ด์ ๋งค์ฐ ๋น์ทํ๊ฒ ์๋ํฉ๋๋ค:
fn main() { let mut x = 10; while x != 1 { x = if x % 2 == 0 { x / 2 } else { 3 * x + 1 }; } println!("Final x: {x}"); }
while
๋ฐ๋ณต๋ฌธwhile
ํค์๋๋ ๋ค๋ฅธ ์ธ์ด์ ๋งค์ฐ ๋น์ทํ๊ฒ ์๋ํฉ๋๋ค:
fn main() { let mut x = 10; while x != 1 { x = if x % 2 == 0 { x / 2 } else { 3 * x + 1 }; } println!("Final x: {x}"); }