MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / fizz_buzz

Function fizz_buzz

412-fizz-buzz.rs:22–36  ·  view source on GitHub ↗
(n: i32)

Source from the content-addressed store, hash-verified

20}
21
22pub 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}

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected