closest_fibonacci 1.2.1 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.2.4
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "closest_fibonacci"
8
- s.version = "1.2.1"
8
+ s.version = "1.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Boris Polania"]
@@ -2,15 +2,20 @@ module SiUnits
2
2
 
3
3
  def closest_fibonacci
4
4
 
5
- f = 0
5
+ def fib(n)
6
+ return n if (0..1).include? n
7
+ fib(n-1) + fib(n-2) if n > 1
8
+ end
9
+
10
+ i = 0
6
11
 
7
- while f < self do
12
+ while fib(i) < self do
8
13
 
9
- f = f + (f + 1)
14
+ i = i + 1;
10
15
 
11
16
  end
12
17
 
13
- f
18
+ fib(i)
14
19
 
15
20
  end
16
21
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: closest_fibonacci
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
9
+ - 4
10
+ version: 1.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Boris Polania