Write a Shell script to find factorial of a given integer.

AIM:

Write a  Shell script  to find factorial of a given integer.

Program:

# !/bin/bash
echo "enter a number"
read num
fact=1
while [ $num -ge 1 ]
do
fact=`expr  $fact\* $num`
num=’expr $num – 1’
done
echo "factorial of $n is $fact"

Output:

guest-glcbIs@ubuntu:~$sh lprg7.sh
enter a number
4
Factorial of 4 is 24