Condition in for loop

You can do something like this. But I don’t think it’s worth it :wink:

fun main(args: Array<String>){
      //sampleStart
    val n = 10
    for (i in generateSequence(1) { it + 1 }.takeWhile{ it * it < n })
        println(i)  
      //sampleEnd
}
10 Likes