Factorial - Eleven source code

options
{
  app_name     = "Factorial";
  package_name = "factorial";
}

sub fact (var x)
{
  if (x <= 1)
    {
      return 1;
    }
  else
    {
      return x * fact (x - 1);
    }
}

statesafe var i;

display
{
  print ("Welcome to the factorial program (demonstrating recursive functions).");
  edit ("Input value: ", i);
}

while (1)
{
  statesafe var f = fact (i);

  display
    {
      print ("The factorial of ", i, " is ", f, ".");
      edit ("Enter another input value: ", i);
    }
}