spinix-hive/scripts/fact.sh

23 lines
272 B
Bash
Raw Normal View History

#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