Created
April 11, 2020 13:36
-
-
Save AlAskalany/1318ae0a645cb1c2f72ade086225cb98 to your computer and use it in GitHub Desktop.
FizzBuzz in 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
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