I had looked on overflow and exchange, but I can't seem to find an answer for this. I am currently trying to make a recursive fibonacci function. However when I try to test it (using command line entry) it keeps returning the error
fork: retry: Resource temporarily unavailable
I had found a post saying it had to do with shell resource limits, but I felt like that probably wasn't my issue since I've seen separate posts with recursive functions being able to call their function fine enough.
I had broken up the operation into parts to see what exactly was happening, but I can't find a specific problem - it may have to do with how i'm calling my function, but I'm not sure, either.
I can pass the parameter I want just fine, though. It just prints the same error for whatever number I put in. If I enter 5, it echoes the fork error five times. It returns, but doesn't return the values...
For specification, I currently use Bash Version 4.4.20(1)
function fib_r
{
int=$1
for ((i=1; i<=int; i++))
do
f1=$(fib_r $((int-1)))
f2=$(fib_r $((int-2)))
fibo=$((f1+f2))
done
}
What I want to achieve is when you enter a number on command line, It does calculate that number, however it shows the calculated number at each step, rather than return the final value from start to end:
An example output:
1 1
2 1
3 2
4 3
5 5
6 8
7 13
8 21
9 34
10 55