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
What are Attributes in HTML langauge? A few tags have attributes. An attribute is a name, followed through an = sign, followed by the value. For instance, to make a centered H1

The next major set of tasks to tackle are delete and update. Version control systems typically version updates to a ?le and only store the differences between the ?les. Two system

In this activity, you are going to place components on a sheet and connect them with virtual wires to create a simple digital circuit. You will simulate the circuit to verify the c

One of the main strengths of the Perl programming language are its powerful text manipulation features. In this assignment, you will put them to use for writing a Perl program that

Before I describe what you are supposed to do, please remember that this programming assignment is NOT a group project. You are NOT allowed to do this with anyone else's help. This

Example problem Imagine that  you  require  to create  a robot  that  will  roll up  close to a light  lamp  and  stop  a fixed distance from it.  The first question is, how w

I need help programming an arduino uno to scan an ean-8 student barcode and display their name and id on computer. This is a capstone project.

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

Introduction A new online system for purchasing carsis being designed and you have been contracted to write a C# console application program that models the proposed functio

Example- Arithmetic :  Given the subsequent two matrices, So calculate A-5B. Solution There isn't much to do now other than the work. We first multiplied