Hi,


I am trying to run the factorial script but itís not working.

The code is mentioned below:
------------------------------------------------------------------
/home/gc> cat fact.sh
#!/bin/bash
# using one command line parameter

factorial=1
for (( number = 1; number <= $1 ; number++ ))
do
factorial=$[ $factorial * $number ]
done
echo The factorial of $1 is $factorial
------------------------------------------------------------------
Execution:
/home/gc> bash -x fact.sh 5
+ factorial=1
fact.sh: syntax error near unexpected token `(('
fact.sh: fact.sh: line 5: `for (( number = 1; number <= $1 ; number++ ))'
------------------------------------------------------------------

Can anyone please help?


Regards,
GC