Код для справки.
Код: Выделить всё
#!bin/bash
fib=(0 1)
read -p "Enter the nth term you want to generate based on the fibbonaci sequence: " input
for((i = 2; i < $input; i++)); do
echo "Value at Last Index $((fib[-1]))"
echo "Second Last Value: $((fib[-2]))"
lastNum=$((fib[-1]))
secondLastNum=$((fib[-2]))
fibNum=$((lastNum + secondLast))
echo "New Number to be Added: $fibNum"
$fib+=("$fibNum")
done
Подробнее здесь: https://stackoverflow.com/questions/787 ... ay-in-bash
Мобильная версия