Skip to content

Commit 516760d

Browse files
committed
Add solution 412
1 parent 9aefcb2 commit 516760d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

412_FizzBuzz.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
func fizzBuzz(_ n: Int) -> [String] {
3+
var result = [String]()
4+
for i in 1...n {
5+
if i%3==0 && i%5==0 {
6+
result.append("FizzBuzz")
7+
} else if i%3==0 {
8+
result.append("Fizz")
9+
} else if i%5==0 {
10+
result.append("Buzz")
11+
} else {
12+
result.append(String(i))
13+
}
14+
}
15+
return result
16+
}
17+
}

0 commit comments

Comments
 (0)