RosettaCodeData/Task/Factorial/UNIX-Shell/factorial-3.sh

8 lines
105 B
Bash

factorial ()
{
if [ $1 -eq 0 ]
then echo 1
else echo $(($1 * $(factorial $(($1-1)) ) ))
fi
}