factorial () {
if (($1 == 1))
then
echo 1
return
else
echo $(( $( factorial $(($1 - 1)) ) * $1 ))
fi
}
function factorial {
typeset n=$1
(( n < 2 )) && echo 1 && return
echo $(( n * $(factorial $((n-1))) ))
}