/euler-number-two

Reusable solution to Project Euler Problem 2.

Primary LanguageRubyMIT LicenseMIT

Euler::Number::Two

Even Fibonacci numbers - Problem 2

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. See https://projecteuler.net/problem=2

Installation

Add this line to your application's Gemfile:

gem 'euler-number-two'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install euler-number-two

Usage

Euler::Number::Two.sum_even_fibs_smaller_than_4_mill # => 4613732

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bsbodden/euler-number-two.

License

The gem is available as open source under the terms of the MIT License.