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
Write a program to show ten buttons with five possible colors: red, green, orange, yellow, blue. When the user clicks on a button, its color must advance to the next color, or go b

Expertsmind brings you unique solution in java assignments Applet In processing, and the apple company is any little application that works one specific process that works

Overview Goals: The goals for this assignment are Design and implement instantiable classes. Use arrays of objects. Read from and write to files. Implement basic

1. Write out a detailed plan for a program to find the largest value in an array that is smaller than a ceiling C. For example, suppose the array has the values {4, 14, 11, 100, 6}

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

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

how to save bulk entries at a time using collections?

Question: (a) In JavaScript, the Window Object is commonly used to request information from a user or to output some results. Give three ways how to create instances of the

W.A.S.S to find the maximum of three numbers Program # W.A.S.S to find the maximum of three numbers echo "Enter three No.:" read no1 read no2 read no3 if test $no1 -gt $n

I have doubt in this section .do-while loop.could you able to clear it for me.