closest_fibonacci 1.2.1 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/closest_fibonacci.gemspec +1 -1
- data/lib/closest_fibonacci.rb +9 -4
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.4
|
data/closest_fibonacci.gemspec
CHANGED
data/lib/closest_fibonacci.rb
CHANGED
@@ -2,15 +2,20 @@ module SiUnits
|
|
2
2
|
|
3
3
|
def closest_fibonacci
|
4
4
|
|
5
|
-
|
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
|
12
|
+
while fib(i) < self do
|
8
13
|
|
9
|
-
|
14
|
+
i = i + 1;
|
10
15
|
|
11
16
|
end
|
12
17
|
|
13
|
-
|
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:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 4
|
10
|
+
version: 1.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Boris Polania
|