Created
February 20, 2021 23:56
-
-
Save chinnonsantos/2d89fc0857b86f05db9eec37c71d3857 to your computer and use it in GitHub Desktop.
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 fizzbuzz(start: Int, end: Int) { | |
for (k in start..end) { | |
fun isFizz() = k % 3 == 0 | |
fun isBuzz() = k % 5 == 0 | |
when { | |
isFizz() && isBuzz() -> println("Fizz Buzz") | |
isFizz() -> println("Fizz") | |
isBuzz() -> println("Buzz") | |
else -> println(k) | |
} | |
} | |
} | |
fun main() { | |
fizzbuzz(start = 1, end = 15) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment