//
// program to count down from n to 0 (print numbers from n to 0)
//

// the next line is needed to avoid warnings with the newest Scala
// "comment it out" (insert a //) if you compile with an earlier version
import scala.io.StdIn._

def countdown(n : Int) {
  if (n < 0) {
    println("Done")
  }
  else {
    // reverse the order of these two statements to count up
    println(n)
    countdown(n-1)
  }
}

// main program -- prompt for input and call function

println("enter the starting number (>= 0):")
val num = readInt
if (num < 0) {
  println("too small!")
}
else {
  countdown(num)
}