RosettaCodeData/Task/Loops-Do-while/Scala/loops-do-while-1.scala

9 lines
179 B
Scala
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
{
var (x, l) = (0, List[Int]())
do {
x += 1
l :+= x // A new copy of this list with List(x) appended.
} while (x % 6 != 0)
l
}.foreach(println(_))