How to calculate factorial of number n entered by user

 

Linux Bash Script

i=$1
temp=1
while [[ $i -gt 1 ]]
do
        let temp=$temp*$i
        let i=$i-1
done
echo $temp

 

Execute the Linux Script

./4_factorial.sh 5

 

Output of Linux Script

120