Friday, 27 March 2015

Shell Script to Find Factorial of a Number

3)write a Shell Script to Find Factorial of a Number?
clear
echo "enter number"
read fact

ans=1
counter=0
while [ $fact -ne $counter ]
do
counter=`expr $counter + 1`
ans=`expr $ans \* $counter`
done
echo "Total of factorial is $ans"

No comments:

Post a Comment