斐波那契数列
fibonacciSequenceFun.sh
#!/bin/bash
function fibonacci_sequence {
if [ $1 -eq 0 ]; then
echo 0
elif [ $1 -eq 1 ]; then
echo 1
else
# echo $[`fibonacci_sequence $[$1-1]` + `fibonacci_sequence $[$1-2]`]
echo $[$(fibonacci_sequence $[$1-1]) + $(fibonacci_sequence $[$1-2])]
fi
}
fibonacciSequence.sh
#!/bin/bash
. fibonacciSequenceFun.sh
原创文章,作者:songzizhe,如若转载,请注明出处:http://www.178linux.com/40258