Write a shell script to find the factorial of a given number, Programming Languages

 W.A.S.S to find the factorial of a given number.

Program

# W.A.S.S to find the factorial of a given number.
  

echo -e "enter number:\c"            #  \c Suppress trailing newline, –e Backslash-escaped
 #  characters  is enabled
read number
i=1
f=1

while test $i -le $number
do
f=`expr $f \* $i`                     # expression is written in back quote because it will produce output at
     # runtime
i=`expr $i + 1`
done                                       # ‘done’ is completion of while loop

echo "factorial of number is:$f"

Output

enter number:4
factorial of number is:24

Posted Date: 9/26/2012 4:24:40 AM | Location : United States







Related Discussions:- Write a shell script to find the factorial of a given number, Assignment Help, Ask Question on Write a shell script to find the factorial of a given number, Get Answer, Expert's Help, Write a shell script to find the factorial of a given number Discussions

Write discussion on Write a shell script to find the factorial of a given number
Your posts are moderated
Related Questions
how to make a program using vb?seriously i don''t know

I need help with having a user input a year, and my program to spit out what day of the week Christmas is on.... any helping hands on this?

How to i write a car rental program in jgrasp

about how to create the program in c

these 8 numbers (15, 20, 25, 30, 35, 40, 45, and 50) with using conditional jump

need someone to write a simple cobol program for me..urgent

How do i get back data from a FOR loop in order to print them on screen?

#question.what. is cai? Explain its pitfalls .o

Hi, Can any of you, tell me how to use Included Applications?

(a) Write a recursive procedure (digits n) that computes the number of digits in the integer n using a linear recursive process. For example, (digits 42) should return 2 and (digit