title: Print Fibonacci series using recursion in bash with only 1 variable
body: <p>I'd like to know how to print Fibonacci series using recursion in bash with only 1 variable.</p>
  
  <p>From what I've done:</p>
  
  <pre><code>fib()
      {
      i=$1
      if (( $i &lt;= 1 ))
      then echo 0
      elif (( $i == 2 ))
      then echo 1
      else
  
      echo $(( $(fib $(($i - 1)) ) + $(fib $(($i - 2)) ) ))
  
  fi
   }
  
  echo $(fib $1)
  </code></pre>
  
  <p>I get the correct output of the final iteration, for example if I enter 10 I will get 34, but I'd like to print the whole sequence of numbers, i.e. all the iterations as well. How can I achieve that?</p>
  
  <p>Another way I tried was by:</p>
  
  <pre><code>#!/bin/bash
  arr[0]=0
  arr[1]=1
  
  for (( i=0; i&lt;=10; i++ ))
  do
      echo -n "${arr[0]} "
      arr[0]=$((${arr[0]} + ${arr[1]} ))
      arr[1]=$((${arr[0]} - ${arr[1]} ))
  done
  echo ""
  </code></pre>
  
  <p>But obviously here I've used a for loop, but I don't want to use another variable.</p>