Created
February 27, 2018 14:25
-
-
Save kmdsbng/f70ba343ad31bbaff98318dc25b18e04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 基本問題 | |
fun main(args: Array<String>) { | |
val values = generateFizzBuzz() | |
values.forEach { | |
println(it) | |
} | |
} | |
private fun generateFizzBuzz(): List<Any> { | |
val values = (1..100).map { | |
when { | |
(it % 15 == 0) -> { | |
"FizzBuzz" | |
} | |
(it % 5 == 0) -> { | |
"Buzz" | |
} | |
(it % 3 == 0) -> { | |
"Fizz" | |
} | |
else -> { | |
it | |
} | |
} | |
} | |
return values | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment