Skip to content

Instantly share code, notes, and snippets.

@AlAskalany
Created April 11, 2020 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlAskalany/1318ae0a645cb1c2f72ade086225cb98 to your computer and use it in GitHub Desktop.
Save AlAskalany/1318ae0a645cb1c2f72ade086225cb98 to your computer and use it in GitHub Desktop.
FizzBuzz in Kotlin
fun main(args: Array<String>) {
(1..100).forEach {
val divBy3 = it%3 == 0
val divBy5 = it%5 == 0
if(divBy3) {
if(divBy5) {
println("FizzBuzz")
} else {
println("Fizz")
}
} else if(divBy5) {
println("Buzz")
} else {
println(it)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment