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
need someone to write a simple cobol program for me..urgent

Padovan String Problem Description A Padovan string P(n) for a natural number n is defined as: P(0) = 'X' P(1) = 'Y' P(2) = 'Z' P(n) = P(n-2) + P(n-3), n

Draw the sequence diagram for the following scenario of eBroker. Sell Stock The user enters the username and password The system checks that the user is a valid user

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

Task .Task 1 Database design This task will allow you to demonstrate the following Learning Outcomes (LOs): LO 2. Justify the design and development of the application and critica

Describe URL and hostname part? The hostname part of the URL should be a valid Internet hostname. It can also be an IP address like as 204.29.207.217 or 128.235.252.184. The

(a) (i) What do you meant  by a function? Are functions required when writing a C program? (ii) State one of the advantages to the use of functions. (iii) What do you meant by a

Question 1: a) Assume that B is an array of 50 words; write a code which will place the smallest integer of array B in register AX. b) Write a small code (only three instr

Write a program that takes names of 5 students in 2D Character Array and their GPAs in 1D array. Arrange the names in alphabetical order and display on screen along with GPA.