factorialsh 2 the factorial of 2 is 2 factorialsh 4 the fa
$ ./factorial.sh 2
the factorial of 2 is 2
$ ./factorial.sh 4
the factorial of 4 is 24
$ ./factorial.sh 5
the factorial of 4 is 120
Writing in Ubuntu terminal. Need help. Thank you
Solution
#!/bin/bash
# testing the REPLY environment variable
read -p \"Enter a number: \"
factorial=1
for((count = 1;count<=$REPLY ;count++))
do
factorial=$[ $factorial * $count ]
done
echo \"The factorial of $REPLY is $factorial\"
