Custom Search

Friday 20 April 2012

Write a Linux shell script to find factorial of a given number, Unix program to find factorial of n numbers


Write a Linux shell script to find factorial of a given number, Unix program to find factorial of n numbers


Program
clear
echo "Enter the number:"
read n


fact=1


for ((i=1;i<=n;i++))
do
  fact='expr$fact\*$i'
done


echo "Factorial:"$fact




Output
Enter the number
4
Factorial:24
<<< Previous  ||  Current  ||  Next >>>  

No comments:

Post a Comment

Laptops