Skip to content

Instantly share code, notes, and snippets.

@chinnonsantos
Created February 20, 2021 23:52
Show Gist options
  • Save chinnonsantos/5fc8cfe309ad376235b58e14a04f045d to your computer and use it in GitHub Desktop.
Save chinnonsantos/5fc8cfe309ad376235b58e14a04f045d to your computer and use it in GitHub Desktop.
fun fizzbuzz(start: Int, end: Int) {
for (k in start..end) {
fun isFizz() = k % 3 == 0
fun isBuzz() = k % 5 == 0
if (isFizz() && isBuzz())
println("Fizz Buzz")
else if (isFizz())
println("Fizz")
else if (isBuzz())
println("Buzz")
else
println(k)
}
}
fun main() {
fizzbuzz(start = 1, end = 15)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment