title: How can I validate this sequence F(x)=F(x+y)+F(x-z) to be used in my function?
body: <p>I am writing a program that makes use of the Fibonacci sequence: <em>F(n)= F(n-1) + F(n-2)</em>. The program will take in a user's input which will be a number and output the sequence $F(x)$. As an additional task, I have been asked to accept two additional inputs from the user <strong>y and z</strong> where <em>F(x)= F(x-y) + F(x-z)</em> and output the sequence of numbers. If a number does not exist in the sequence output a 1 instead. The Fibonacci sequence seems to be working fine, but I am not sure if I have the <em>F(x)=F(x+y)+F(x-z)</em> sequence correct. Below is a code snippet of the function that handles both sequences:</p>
  <pre class="lang-js prettyprint-override"><code>function fibonacci(x, y, z) {
      let fibos = [];
      fibos[0] = 1;
      fibos[1] = 1;
      fibos[2] = 2;
      if (y !== '' &amp;&amp; z !== '') {
        for (let i = 3; i &lt; x; i++){
          fibos[i] = fibos[x -y] + fibos[x - z]
        }
      } else {
        for (let i = 3; i &lt; x; i++){
          fibos[i] = fibos[i -1] + fibos[i -2]
        }
      }
      return fibos;
  }
  </code></pre>
  <p>The function above, takes in three arguments <strong>x,y,z</strong>. If y and z are not initialized the function will use the second sequence which is the fibonacci, however, if they are initialized it uses the function under question which again is <em>F(x)=F(x+y)+F(x-z)</em>. So my question is do I have the function programmatically correct and how would I understand this mathematically?</p>