Skip to content

Instantly share code, notes, and snippets.

View abreslav's full-sized avatar

Andrey Breslav abreslav

View GitHub Profile
fun Int.divides(d: Int) = this % d == 0
fun fizzbuzz(n: Int) = when {
n divides 15 -> "fizzbuzz"
n divides 3 -> "fizz"
n divides 5 -> "buzz"
else -> "$n"
}
fun result(max: Int) = (0..max) map { n -> fizzbuzz(n) }