Skip to content

Simple Ruby gem that finds the largest integer value from the Fibonacci Sequence smaller than the given integer.

License

Notifications You must be signed in to change notification settings

lessaworld/Closest-Fibonacci

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

closest_fibonacci

A very simple gem that finds the largest integer value from the Fibonacci Sequence smaller than the given integer (see sample usage below).

156.closest_fibonacci => 144

99.closest_fibonacci => 89

How to install it

This gem hasn’t been published in rubygems.org but you can download it directly from this git repo and quickly install it in your local repository.

ruby -S gem install ./pkg/closest_fibonacci-0.3.0.gem

Usage

require 'closest_fibonacci'

puts 0.closest_fibonacci
puts 2.closest_fibonacci
puts 156.closest_fibonacci
puts 99.closest_fibonacci
#
# Prints:
# 0
# 1
# 144
# 89

Implementation Details

The beauty of this implementation is that it has a linear performance defined as O(n).

Contributing to closest_fibonacci

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 Andre Lessa. See LICENSE.txt for further details.

About

Simple Ruby gem that finds the largest integer value from the Fibonacci Sequence smaller than the given integer.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages