2023-10-30 05:23:43 +00:00
|
|
|
// FizzBuzz, using the unstable variadic-`print` builtin
|
|
|
|
|
|
|
|
fn main() {
|
2024-04-19 15:49:25 +00:00
|
|
|
fizzbuzz(10, 20)
|
2023-10-30 05:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Outputs FizzBuzz for numbers between `start` and `end`, inclusive
|
2024-04-19 15:49:25 +00:00
|
|
|
fn fizzbuzz(start: i128, end: i128) {
|
2023-10-30 05:23:43 +00:00
|
|
|
for x in start..=end {
|
|
|
|
print(if x % 15 == 0 {
|
|
|
|
"FizzBuzz"
|
|
|
|
} else if 0 == x % 3 {
|
|
|
|
"Fizz"
|
|
|
|
} else if x % 5 == 0 {
|
|
|
|
"Buzz"
|
|
|
|
} else {
|
|
|
|
x
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|