factorial=1
for ((index=1 ; index <= $1 ; index++ ))
do
factorial=`expr $index \* $factorial`
done
echo "Factorial of $1 = $factorial"
OUTPUT:-
#!/bin/bash
#[root@localhost scripts]# ./factorial 5
#Factorial of 5 = 120
for ((index=1 ; index <= $1 ; index++ ))
do
factorial=`expr $index \* $factorial`
done
echo "Factorial of $1 = $factorial"
OUTPUT:-
#!/bin/bash
#[root@localhost scripts]# ./factorial 5
#Factorial of 5 = 120
0 comments:
Post a Comment