In shell scripting how to find factorial of a number?
There are a number of instructive examples on Rosetta Code.
Here's one I found particularly useful:
function factorial { typeset n=$1 (( n < 2 )) && echo 1 && return echo $(( n * $(factorial $((n-1))) )) }