17 lines
385 B
Rust
17 lines
385 B
Rust
pub fn fizz_buzz(number: i32) -> Vec<String> {
|
|
let mut result = vec![];
|
|
|
|
for index in 1..=number {
|
|
let string = match (index % 3 == 0, index % 5 == 0) {
|
|
(true, true) => "FizzBuzz".to_string(),
|
|
(true, false) => "Fizz".to_string(),
|
|
(false, true) => "Buzz".to_string(),
|
|
(false, false) => index.to_string(),
|
|
};
|
|
|
|
result.push(string);
|
|
}
|
|
|
|
result
|
|
}
|