Skip to content

Instantly share code, notes, and snippets.

@theWhiteFox
Last active January 14, 2018 12:15
Show Gist options
  • Select an option

  • Save theWhiteFox/d6f0b7869b51b319f2f24ff180e092ae to your computer and use it in GitHub Desktop.

Select an option

Save theWhiteFox/d6f0b7869b51b319f2f24ff180e092ae to your computer and use it in GitHub Desktop.

Revisions

  1. Ó Conchubhair ♔ revised this gist Jan 14, 2018. 1 changed file with 1 addition and 6 deletions.
    7 changes: 1 addition & 6 deletions fibonacciRecursive.js
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,12 @@
    // recursive. output starts at 0
    function fib(number) {

    if(number == 0) return 0;

    if(number == 0) return 0;
    if(number == 1) return 1;

    return fib(number - 2) + fib(number - 1);

    }

    // shorter recursive. output starts at 1
    function fibRecursive(n) {
    if(n <= 1) return 1;

    return fibRecursive(n - 2) + fibRecursive(n - 1);
    }
  2. Ó Conchubhair ♔ created this gist Jul 2, 2017.
    17 changes: 17 additions & 0 deletions fibonacciRecursive.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    // recursive. output starts at 0
    function fib(number) {

    if(number == 0) return 0;

    if(number == 1) return 1;

    return fib(number - 2) + fib(number - 1);

    }

    // shorter recursive. output starts at 1
    function fibRecursive(n) {
    if(n <= 1) return 1;

    return fibRecursive(n - 2) + fibRecursive(n - 1);
    }