I have a program on bash which calculates n'th number of Fibonacci seq. But keep getting an error expr: syntax error
. As I understand this is because I return something from function in wrong way, but I dont understand how to make it right. Here is my code:
fib() {
if (( $1 < 2 ))
then
return 1
fi
c=$(fib `expr $1 - 1`)
b=$(fib `expr $1 - 2`)
echo "$b $c"
#Here I have a blank line in output
#So I thought may be the problem is about returning/reception values?
return `expr $c + $b`
}