标签:ash pre width alt image com shell sharp nbsp
1.n的阶乘。
#! # f() { if [ $1 -lt 1 ];then echo 1 else i=$[$1*$(f $[$1-1])] echo $i fi } f 5

2.斐波那契函数。(1,1,2,3,5,8,13,21,34,55....)
#!/bin/bash
#
fact() {
if [ $1 -lt 3 ];then
echo 1
else
i=$[$(fact $[$1-1])+ $(fact $[$1-2])]
echo $i
fi
}
fact 8
![]()
标签:ash pre width alt image com shell sharp nbsp
原文地址:https://www.cnblogs.com/COO-zsy/p/11589522.html