Factorial in Unix shell

Example for versions Bash 4.0.35

This example uses iterative factorial definition.

f=1

for (( n=1; $n<=17; $((n++)) ));
do
  echo "$((n-1))! = $f"
  f=$((f*n))
done