SHELL SCRIPT TO FIND FACTORIAL | URDINESH

Software Programming, Tutorials, Interview Preparations,Stock Market,BSE/NSE, General informations

Sunday, July 19, 2015

SHELL SCRIPT TO FIND FACTORIAL

FACTORIAL
clear
#factorial of n numbers
echo "enter the number"
read num
fact=1
for((i=1;i<num+1;i++))
do
fact=`expr $fact \* $i`
done
echo "the factorial of $num is $fact"













OUTPUT:
enter the number
5
the factorial of 5 is 120

[2k7ca324@localhost ~]$

No comments:

Post a Comment

Thanks for your valuable comments

Followers