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
The following function calls supposedly write a single new-line character, but some are incorrect. Identify which calls don't work and explain why.     printf("%c", '\n');

How do you print triangles using for loops and if statements

I need to write code to compute matrix multiplication without using built in function.

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

What are Relative URLS ? When a web browser reads an HTML document, it has a great deal of information about the document. This includes the protocol used to retrieve the docu

Develop (i) a context diagram, and (ii) a use case diagram to model the following functionalities of an online brokerage house. eBroker is a discount online broker. An account h

Define an Example of Switch Statement? estimate(number) int number; /* Estimate a number as none, one, two, several, many */ {       switch(number) { case 0 :

Support for Multi-Targeting The multi-targeting function of Vision Facilities allows you specify the particular edition or account of the .NET Structure that is required for your p

Windows XP using C# load a binary file and send it thru a USB port to the USB port of STM32. STM32 received the file and then write it into an I2C EEPROM.

I need to do image reconstruction using Neural Network using Matlab