@TCL_STARTUP@

# fac.tcl
#
# This Tcl script computes factorials.

proc factorial x {

    if {$x <= 1} {
        return 1;
    }

    expr $x * [factorial [expr $x - 1]]
}

set number 0

while {$number != -1} {

  puts "Enter a nonnegative integer (-1 to quit): "
  gets stdin number
 
  if {$number != -1} {
    puts "$number! is equal to [factorial $number]\n"
  }
}
