Рекурсия

Функции

fibonacci() {
    local x=$1
    if ((x <= 1)); then
        echo "$x"
        return
    fi
    echo $(($(fibonacci $((x - 1))) + $(fibonacci $((x - 2)))))
}

f10=$(fibonacci 10)
#f10 is 55
#each $( ) starts a new process: deep recursion is slow,
#and FUNCNEST can limit the depth

echo "f10 is $f10"