Skip to content

Instantly share code, notes, and snippets.

@titanium-cranium
Created November 14, 2017 21:03
Show Gist options
  • Save titanium-cranium/92a966f6ea8c31ba140a2b5eda0ae4f5 to your computer and use it in GitHub Desktop.
Save titanium-cranium/92a966f6ea8c31ba140a2b5eda0ae4f5 to your computer and use it in GitHub Desktop.

Revisions

  1. titanium-cranium created this gist Nov 14, 2017.
    6 changes: 6 additions & 0 deletions recursive_fibonacci.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    def fib(n)
    return n if (0..1).include? n
    fib(n-1) + fib(n-2) if n > 1
    end

    puts fib(7)