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
Using OOP,write a sample program to get the factorial of a number entered by a user

Create a visualization (programming project) and demonstrate it in the class. The project should be related to distributed systems. (A distributed system consists of multiple auton

I need help with some simple matlab statements

A non-empty string β is called a repeat pre x of a string s if ββ is a pre x of s. Give a linear time algorithm to find the longest repeat prefix of s. Hint: Think of using lca

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

how to concatinate two strings in assembly


I''m doing a project for class in college and im supposed to use today''s date and figure out how old i am in months, days, minutes, and seconds. My question is what is the beset

Hi, Can you do exercises: D2, D3, D4, and D5 on page 230 of the following book: http://www.daimi.au.dk/~bra8130/Wiley_book/wiley.html . The book can be downloaded for free from t

JavaScript is "Object Oriented" like C++ or Java. (Note that Java and JavaScript are not the same language, which is a common misconception) It also has variables, which makes Java