Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

SHELL SCRIPTING

echo "Enter a number: "

read num

i=2

res=1

if [ $num -ge 2 ]

then

while [ $i -le $num ]

do

res=`expr $res \* $i`

i=`expr $i + 1`

done

echo "Factorial of $num = $res"

You might also like