Skip to content

Instantly share code, notes, and snippets.

@mertceyhan
Created January 31, 2022 21:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mertceyhan/5121baaa53d2c8b6391d086d5e66e03b to your computer and use it in GitHub Desktop.
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