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 that repeatedly prompts for and reads a positive integer value n and then calculates and displays the nth Fibonacci number

Scenario A campsite provides cabins for travellers to stay in overnight. A 'cabin' is a small wooden hut, containing bunk beds, table and chairs, a heater, and a small cookin

**This programming assignment is for use in the LINUX/UNIX environment!! Introduction: System administration often requires custom written programs and tools. One problem a syste

Pseudo code the shows logic for a program that generates a random number, then ask the user to think of a number between 1 and 10

How and where to start to develop a preprocessor for java

write a function that raises an integer to a positive integer power. call the function x_to_the_n taking two integer arguments x and n. have the function return a long int, which r

Question 1 Discuss on Inheritance Question 2 What are the four phases of the object modeling technique that can be repetitively executed? Question 3 Explain the di

Objective: In a programming language of your choice, write an intelligent agent able to play block Dominoes against a player. Together with this assignment you will find two pa

The idea of this section is not to do anything new along with a series solution problem.  Instead this is here to exemplify that moving in a higher order differential equation does

what is the optimal solution for this problem? Max 1A + 1B s.t. 5A +3B 3A + 5B A,B >0