-2

I'm just a begineer in kotlin and I'm am writing the Fizzbuzz program in kotlin but can't. Can anyone help me out?

1 Answers1

2

fun main() {
    for (i in 1..100){
        if ( i%15 == 0) {
            println("FizzBuzz")}
        else if(i%5 == 0) {
            println("Buzz")}
        else if(i%3 == 0){
            println("Fizz")}    
        else {
            println(i)
        }    

    }
}

Please note that, It is not only the way to do it.You can do the fizzbuzz in kotlin in fewer line code than this but this is how I did it.

SawOnGam
  • 142
  • 3