Skip to content

Instantly share code, notes, and snippets.

@mattn
Created March 12, 2015 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/3acf44cf1cda4a5b8343 to your computer and use it in GitHub Desktop.
Save mattn/3acf44cf1cda4a5b8343 to your computer and use it in GitHub Desktop.
fun Int.divides(d: Int) : Boolean {
return this % d == 0
}
fun main(args: Array<String>) : Unit {
var i = 1
iterate { i++ } take 100 forEach {
println(
when (true) {
it divides 15 -> "FizzBuzz"
it divides 3 -> "Fizz"
it divides 5 -> "Buzz"
else -> it
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment