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
Using OOP,write a sample program to get the factorial of a number entered by a user


1) Write a program that takes an input value (for example, a number 5). The output should be sum of all numbers from 1 to the value input by the user (in this example, the output w

fow to I write a emplate that reads a set of numbers typed at the keyboard into an array of T

Identifying the Central Individual in a Social Network 1. Introduction You have just been hired by a social networking company! The division you are working in is particul

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

The last exercise of each assignment will be continuous from assignment to assignment and will have the goal of building an e-store website by the end of the course. For the fir

Write 3 somewhat simple scripts / programs in any language, combination of languages, and/or software. Please tell me the task you are trying to accomplish in the scripts. Idea

Describe briefly how you might program a computer to exhibit fear or sorrow.

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