Skip to content

Instantly share code, notes, and snippets.

@wakwak3125
Last active August 29, 2015 14:23
Show Gist options
  • Save wakwak3125/644445ed260461c53569 to your computer and use it in GitHub Desktop.
Save wakwak3125/644445ed260461c53569 to your computer and use it in GitHub Desktop.
Simple FizzBuzz Kotlin.
fun main(args : Array<String>) {
val fzbz = ::FzBz
fzbz(1000)
}
// countの数までFizzBuzzする
fun FzBz(count : Int) {
for (i in 1..count) {
if (i % 3 == 0 && i % 5 == 0){println("FizzBuzz")}
else if (i % 3 == 0) {println("Fizz")}
else if (i % 5 == 0) {println("Buzz")}
else println(i)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment