factorial ()      # one-parameter function
{
 if (( $1 <= 1 ))
 then
   echo 1                    # echo result to standard output.
 else
   typeset tmp           # declare two local variables.
   typeset result
   (( tmp = $1 - 1 ))
   (( result = `factorial $tmp` * $1 ))
   echo $result        # echo result to standard output.
 fi
}
#
echo factorial 5 = `factorial 5`    # display result.
