Programming Tutorials

(追記) (追記ここまで)

Finding factorial in Shell Script

By: Vivek G in Linux Tutorials on 2011年01月29日 [フレーム]

This shell script demonstrates finding the factorial of a given number.
 n=0
on=0
fact=1 
echo -n "Enter number to find factorial : "
read n
on=$n
while [ $n -ge 1 ]
do
 fact=`expr $fact \* $n`
 n=`expr $n - 1`
done
echo "Factorial for $on is $fact"



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Linux )

Latest Articles (in Linux)

(追記) (追記ここまで)
(追記) (追記ここまで)

Related Tutorials

AltStyle によって変換されたページ (->オリジナル) /