03-some example
Original...Less than 1 minute
fn main() {
// Program entry point
let mut n = 6; // Mutable variable binding
print!("{n}"); // Macro for printing, like printf
while n != 1 {
// No parenthesis around expression
if n % 2 == 0 { // n modulo 2
n /= 2; // divide by 2
} else {
n = 3 * n + 1;
}
print!(" -> {n}“);
}
println!();
}
Powered by Waline v3.1.3