REM PROGRAM   FACT.BAS
Rem Program to find the factorial of numbers until a negative
Rem number is entered.
DO
  CORRECT = 0
  DO WHILE NOT CORRECT
    INPUT "Enter a positive integer(Negative to end)"; n
    IF n = INT(n) THEN CORRECT = 1  ' Ok only if integer
    IF NOT CORRECT THEN PRINT "Not an integer. Re-Enter"
  LOOP
  IF n < 0 THEN EXIT DO
  f = 1
  for i = 2 to n
        f = f * i
  next
  print using "Factorial(##)=#########"; n ; f
LOOP
end
