title: How to make recursive action/mutation in vuex
body: <p>I am trying to find fibonacci sequence using state and a recursive action in vuex. 
  Basically what I am trying here is rewrite this Javascript recursive function with vuex.</p>
  
  <pre><code>function fib(n) {
    if (n &lt; 2){
      return n
    }
    return fib(n - 1) + fib (n - 2)
  }
  </code></pre>
  
  <p>However, even if I am assigning the state to the action, the state's value never change. 
  How can I make it work? I mean... I am struggling with this for a few days, so if you could give me some tips, or ideas, it would really helps.</p>
  
  <p>Thanks. and this is my code below.</p>
  
  <pre><code>import Vue from 'vue';
  import Vuex from 'vuex';
  
  Vue.use(Vuex);
  
  export const store = new Vuex.Store ({
      state: {
          number: 8
      },
      mutations: {
          showTheNumber: (state) =&gt; {
              return state.number
          }
      },
      actions: {
          findFibNum: ({ dispatch, commit, state }) =&gt; {
              if (state.number &lt; 2) {
                  return state.number
              } else {
                  dispatch('findFibNum', state.number - 1) + dispatch('findFibNum', state.number - 2)
              }
              return commit('showTheNumber')// I am not sure if it is redundant 
  
          }
      }
  
  </code></pre>
  
  <p>and this is how I am calling and showing the value of store in the component.</p>
  
  <pre><code>&lt;template&gt;
      &lt;div&gt;
          &lt;input @input="addUserInput"&gt;&lt;/input&gt;
          &lt;p&gt;Counter is: {{ counter }}&lt;/p&gt;   
      &lt;/div&gt;
  
  &lt;/template&gt;
  
  &lt;script&gt;
      export default {
          methods: {
              addUserInput () {
                  this.$store.dispatch('findFibNum')
  
              }
          },
          computed: {
              counter(){
                  return this.$store.state.number;
              }
          }
      }
  &lt;/script&gt;
  
  </code></pre>