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
Input to be in the form of a string of less than 256 characters. Assume that this character string (record) can only be of the form: Last Name, First Name, Box number, City, St

How to do socket programming in C

Windows Card Space Windows Card Space (codenamed Info Card), is Windows now-canceled customer application for the Identification Met system. Card Place is an instance of a class of

Design and implement a stringed musical instrument class using the following guidelines: a. Data fields for your instrument should include number of strings, an array of stri

Go to the following link and please do Problem 6. This is in C language. http://wikisend.com/download/304748/hw%206.pdf The code I need must be in C language and not C++ . Thank

What is Data Normalization and Schema Refinement? Define briefly..

We want a program that will allow us to print a "grade list" of the students in a class. The program should loop, asking for a name, midterm score, and final score. It should th

write c++ source code to find the number of digits in a given integer? pls ans

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

Given strings s 1 and s 2 of lengths m and n respectively, a minimum cover of s 1 by s 2 is a decomposition s1 = w 1 w 2 .... wk, where each w i is a non-empty substring of s