Skip to content

Instantly share code, notes, and snippets.

@mertceyhan
Created January 31, 2022 21:31
Embed
What would you like to do?
Answer of classic fizzbuzz question with Kotlin
object FizzBuzz {
fun print() {
for (i in 1..100) {
if ((i.rem(3) == 0) and (i.rem(5) == 0)) {
println("FizzBuzz")
} else if (i.rem(3) == 0) {
println("Fizz")
} else if (i.rem(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