I want to do a function that will return the factorial of a number in bash
Here\'s the current code that doesn\'t work, can anyone tell me what\'s wrong and how to c
#-----------------factorial ------------------------ # using eval to avoid process creation fac=25 factorial() { if [[ $1 -le 1 ]] then eval $2=1 else factorial $[$1-1] $2 typeset f2 eval f2=\$$2 ((f2=f2*$1)) eval $2=$f2 fi } time factorial $fac res echo "factorial =$res"