23 lines
272 B
Bash
23 lines
272 B
Bash
#shell
|
|
#This script computes the factorial
|
|
if [ $# -ne 1 ]
|
|
then
|
|
echo usage: fact.sh number
|
|
exit
|
|
fi
|
|
if [ -z $factorial ]
|
|
then
|
|
export factorial=$1
|
|
else
|
|
let factorial=factorial*$1
|
|
fi
|
|
echo .
|
|
if [ $1 -le 1 ]
|
|
then
|
|
echo $factorial
|
|
unset factorial
|
|
else
|
|
let a=$1-1
|
|
./fact.sh $a
|
|
fi
|