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
1 Triple Eigenvalue with 2 Linearly Independent Eigenvectors       In this case we will have the eigen-value l with the two linearly independent eigenvectors  ?h 1 and  ?h 2

The schematic of the traffic light controller is as shown in figure 1. There are three control buttons on the panel: HAZ (Hazard), LT (Left) and RT (Right). Whenever, HAZ is clicke

how do u define a letter in python "NameError: name ''r'' is not defined"

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

Access Modifiers Convenience Modifiers or we can say (Access Specifies) identifies as the opportunity of accessibility of an Item and its associates. All C# kinds and kind associat

how to get horizontal motion vectors field with quiver ?

Explain the Continue statement - Computer Programming? This is alike to break but is encountered less frequently. It merely works within loops where its effect is to force an imm

basic steps involved in spreadsheet developement

Design and implement a stringed musical instrument class using the following guidelines: a. Data fields for your instrument should include number of strings, an array of stri

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