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

8 lines
105 B
Bash
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
factorial ()
{
if [ $1 -eq 0 ]
then echo 1
else echo $(($1 * $(factorial $(($1-1)) ) ))
fi
}