(n: i32)
| 20 | } |
| 21 | |
| 22 | pub fn fizz_buzz(n: i32) -> Vec<String> { |
| 23 | let mut res = vec!(); |
| 24 | for i in 1..n+1 { |
| 25 | if i % 15 == 0 { |
| 26 | res.push("FizzBuzz".to_string()); |
| 27 | } else if i % 3 == 0 { |
| 28 | res.push("Fizz".to_string()); |
| 29 | } else if i % 5 == 0 { |
| 30 | res.push("Buzz".to_string()); |
| 31 | } else { |
| 32 | res.push(i.to_string()); |
| 33 | } |
| 34 | } |
| 35 | res |
| 36 | } |