You can do something like this. But I don’t think it’s worth it
fun main(args: Array<String>){
//sampleStart
val n = 10
for (i in generateSequence(1) { it + 1 }.takeWhile{ it * it < n })
println(i)
//sampleEnd
}
You can do something like this. But I don’t think it’s worth it
fun main(args: Array<String>){
//sampleStart
val n = 10
for (i in generateSequence(1) { it + 1 }.takeWhile{ it * it < n })
println(i)
//sampleEnd
}