linxu shell 递归和while循环 的 factorial计算
linxu shell 递归和while循环 的 factorial计算1
2
3
4
5
6
7
8
91 #!/bin/bash
2 read -p "Enter a number: " num
3 result=$num
4 while [ $num -gt 1 ]
5 do
6 num=$[ $num - 1 ]
7 result=$[ $result * $num ]
8 done
9 echo "The result is $result"
1 | 1 #!/bin/bash |