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
We are need of a PrestaShop Expert We are getting a fresh design created for our Jewellery website. This job is in 2 parts 1. The website engine is PrestaShop as well as w

1. Write a Perl script that accepts exactly 2 integer arguments where the first argument must be less than the second argument. The script will print a comma separated list of inte

Write a program that draws the initials J G P on the form similar to that shown in Fig J 1 (using straight lines and curve semicircles). The figure can not have corners. All ends a

wat is- m=5; n=3; x=m++-n+++m;

Question 1 Discuss on UNIX kernel components 2 Explain process creation and process termination 3 When do a Deadlock occur? What are the Necessary Conditions for Deadlock

Of the 6,325 kindergarten students who participated in the study, almost half or 3,052 were eligible for a free lunch program. The categorical variable sesk (1 == free lunch, 2 = n

P4's goal is to design the C# classes needed to track creature viability in a MMO game under development .  Part I: Class design 1)  GameCreature class (with derived ty

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

The program output is intended to be parsed by a script working on the log file or correlated in a spreadsheet.  Use the "csv" format (you will have to research "what" is a "csv" f

How to i write a car rental program in jgrasp