Created
January 31, 2022 21:31
-
-
Save mertceyhan/5121baaa53d2c8b6391d086d5e66e03b to your computer and use it in GitHub Desktop.
Answer of classic fizzbuzz question with Kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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