mirror of
https://github.com/ahgamut/rust-ape-example.git
synced 2024-05-15 10:02:42 +00:00
29 lines
474 B
Rust
29 lines
474 B
Rust
// ./src/flow_control/while.md
|
|
|
|
|
|
fn part0() {
|
|
// A counter variable
|
|
let mut n = 1;
|
|
|
|
// Loop while `n` is less than 101
|
|
while n < 101 {
|
|
if n % 15 == 0 {
|
|
println!("fizzbuzz");
|
|
} else if n % 3 == 0 {
|
|
println!("fizz");
|
|
} else if n % 5 == 0 {
|
|
println!("buzz");
|
|
} else {
|
|
println!("{}", n);
|
|
}
|
|
|
|
// Increment counter
|
|
n += 1;
|
|
}
|
|
}
|
|
|
|
pub fn main() {
|
|
part0();
|
|
}
|
|
|