Write a Shell script to find factorial of a given integer.
AIM:
Write a Shell script to find factorial of a given integer.
Program:
# !/bin/bash
echo "enter a number"
read num
fact=1
while [ $num -ge 1 ]
do
fact=`expr $fact\* $num`
num=’expr $num – 1’
done
echo "factorial of $n is $fact"
Output:
guest-glcbIs@ubuntu:~$sh lprg7.sh
enter a number
4
Factorial of 4 is 24
-
UpdatedNov 05, 2014
-
Views122,797
You May Like
Write a Shell script to find factorial of a given integer.
Write in C the following Unix commands using system calls A). cat B). ls C). mv
Write a Shell script that displays list of all the files in the current directory to which the user has read, Write and execute permissions.
Write a Shell script that accepts a filename, starting and ending line numbers as arguments and displays all the lines between the given line numbers.
Write a C program to emulate the Unix ls-l command.
Write a Shell script to list all of the directory files in a directory.