/fibonacci

A fibonacci sequence number finder.

Primary LanguageRubyMIT LicenseMIT

Fibonacci

By Scott Hale

Description

Fibonacci Quickly find the nth number* in the Fibonacci sequence (1,1 style).

*Note: Because of the recursion used in the calculation, passing a number much bigger than 20 could take quite a while to calculate...not recommended!

Installation

require 'fib.rb'

Usage

To use Fibonacci, just pass the nth number you're after into the Fib.nth class method

Fib.nth(3) # => 2
Fib.nth(7) # => 13

How It Works

Within the fib.rb file in the lib folder, class Fib introduces a class method where recursion is used to calculate all nth numbers in the sequence (except for the first & second numbers: 1 and 1).

Authors

  • Scott Hale (bozcotty)

Collaborators and Sources