Skip to content

Commit a97c241

Browse files
committed
Sync LeetCode submission - Fizz Buzz (scala)
1 parent b59e73d commit a97c241

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

problems/fizz_buzz/solution.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
object Solution {
2+
def fizzBuzz(n: Int): List[String] = {
3+
4+
val a = (1 to n).toList
5+
val b = a.map(x =>
6+
if (x % 15 == 0) { "FizzBuzz" }
7+
else if (x % 5 == 0) { "Buzz" }
8+
else if (x % 3 == 0) { "Fizz" }
9+
else x.toString()
10+
)
11+
12+
return b
13+
}
14+
}

0 commit comments

Comments
 (0)