Skip to content

Instantly share code, notes, and snippets.

@kmdsbng
Created February 27, 2018 14:25
Show Gist options
  • Save kmdsbng/f70ba343ad31bbaff98318dc25b18e04 to your computer and use it in GitHub Desktop.
Save kmdsbng/f70ba343ad31bbaff98318dc25b18e04 to your computer and use it in GitHub Desktop.
// 基本問題
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