Definitions

   The factorial of   0   (zero)   is defined as being   1   (unity).
   The   Factorial Function   of a positive integer,    n,    is defined as the product of the sequence:
                 n,   n-1,   n-2,   ...   1 



Task

Write a function to return the factorial of a number.

Solutions can be iterative or recursive.

Support for trapping negative    n    errors is optional.



Related task

   Primorial numbers


A factorial is a number.
 
To run:
  Start up.
  Demonstrate input.
  Write "Bye-bye!" to the console.
  Wait for 1 second.
  Shut down.
 
To demonstrate input:
  Write "Enter a number: " to the console without advancing.
  Read a string from the console.
  If the string is empty, exit.
  Convert the string to a number.
  If the number is negative, repeat.
  Compute a factorial of the number.
  Write "Factorial of the number: " then the factorial then the return byte to the console.
  Repeat.
 
To decide if a string is empty:
  If the string's length is 0, say yes.
  Say no.
 
To compute a factorial of a number:
  If the number is 0, put 1 into the factorial; exit.
  Compute another factorial of the number minus 1.  \ recursion
  Put the other factorial times the number into the factorial.