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






Your posts are moderated
Related Questions
The software development team identified the following classes based on the analysis of given requirements: Product, Employee, ProductList, Supplier. 1.  Identify the relationsh

The last exercise of each assignment will be continuous from assignment to assignment and will have the goal of building an e-store website by the end of the course. For the fir

The objectives of this assignment are to test your ability to create XML documents to contain well-defined information. This assignment will be used further in Assignment 2, so ple

You get a contract to implement a simple Java application that process NBA team roster : your application has to read the NBA team roster from a text file and then print each playe

.NET Windows Services But Enthusiasm has an amazing record of beginning overdue but finding up easily. This is real in situation of .NET too. Enthusiasm put their best men at

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

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

On a single XHTML page, include the following two div container elements in the body. Using an external stylesheet, add style to the div elements such that one div has some overlap

Question 1 How to call a WML Script from a WML Page? Question 2 Write short notes on WML Script Operators and Expressions Question 3 Write short notes on WML Script Statements

The Lost Bay Software Coop purchased EnviroMeasurements, a small startup with a product, GreenStation, that measures pollen count and air quality. The company has ventured