函数脚本
#/bin/bash
read -p "输入数字:" N
fac(){
if [ $1 = 1 ]
then
echo 1
else
tmp=$[$1-1]
result=$(fac $tmp)
echo $[$1 * $result]
fi
}
result=$(fac $N)
echo $result
执行效果
[root@localhost ~]# ./jiechen.sh
输入数字:6
720
转载请注明原文地址:https://blackberry.8miu.com/read-35821.html