fibon 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -1
- data/lib/fibon.rb +26 -0
- data/lib/fibon.rb~ +27 -1
- data/lib/fibon/version.rb +1 -1
- data/lib/fibon/version.rb~ +1 -1
- data/lib/main.rb~ +10 -0
- metadata +3 -2
data/README.md
CHANGED
@@ -18,7 +18,10 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
The command
|
21
|
+
The command Fibon.place(number) will generate the value at that point in the sequence.
|
22
|
+
|
23
|
+
A second Method Fibonacci.check(number) will now determine if the given number is a fibonacci number.
|
24
|
+
The method will see if the result of (5X^2)+4 or (5X^2)-4 is a square root.
|
22
25
|
|
23
26
|
## Contributing
|
24
27
|
|
@@ -27,3 +30,13 @@ The command Fibonacci.place(number) will generate the value at that point in the
|
|
27
30
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
31
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
32
|
5. Create new Pull Request
|
33
|
+
|
34
|
+
## Versions
|
35
|
+
|
36
|
+
Version 0.0.4
|
37
|
+
|
38
|
+
Added a method that can determine if a given number is a fibonacci number.
|
39
|
+
|
40
|
+
Version 0.0.1
|
41
|
+
|
42
|
+
Added the basic generator for creating a Fibonacci number based on a position on a number board.
|
data/lib/fibon.rb
CHANGED
@@ -4,4 +4,30 @@ module Fibon
|
|
4
4
|
def self.place(a)
|
5
5
|
@x = ((1 / Math::sqrt(5))*(((1+Math::sqrt(5))/2)**(a))).round
|
6
6
|
end
|
7
|
+
|
8
|
+
def self.check(a)
|
9
|
+
value = false
|
10
|
+
|
11
|
+
firstcheck = (5*(a**2))+4
|
12
|
+
secondcheck = (5*(a**2))-4
|
13
|
+
|
14
|
+
if (self.isPerfectSquare(firstcheck) == true) or (self.isPerfectSquare(secondcheck) == true)
|
15
|
+
value = true
|
16
|
+
else
|
17
|
+
|
18
|
+
end
|
19
|
+
value
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.isPerfectSquare(x)
|
23
|
+
value = false
|
24
|
+
if Math::sqrt(x) == Math::sqrt(x).round
|
25
|
+
value = true
|
26
|
+
else
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
value
|
31
|
+
end
|
32
|
+
|
7
33
|
end
|
data/lib/fibon.rb~
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
require "fibon/version"
|
2
2
|
|
3
3
|
module Fibon
|
4
|
-
|
4
|
+
def self.place(a)
|
5
|
+
@x = ((1 / Math::sqrt(5))*(((1+Math::sqrt(5))/2)**(a))).round
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.check(a)
|
9
|
+
value = false
|
10
|
+
firstcheck = (5*(a**2))+4
|
11
|
+
secondcheck = (5*(a**2))-4
|
12
|
+
if (self.isPerfectSquare(firstcheck) == true) or (self.isPerfectSquare(secondcheck) == true)
|
13
|
+
value = true
|
14
|
+
else
|
15
|
+
|
16
|
+
end
|
17
|
+
value
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.isPerfectSquare(x)
|
21
|
+
value = false
|
22
|
+
if Math::sqrt(x) == Math::sqrt(x).round
|
23
|
+
value = true
|
24
|
+
else
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
value
|
29
|
+
end
|
30
|
+
|
5
31
|
end
|
data/lib/fibon/version.rb
CHANGED
data/lib/fibon/version.rb~
CHANGED
data/lib/main.rb~
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fibon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Fibonacci number Generator
|
15
15
|
email:
|
@@ -29,6 +29,7 @@ files:
|
|
29
29
|
- lib/fibon.rb~
|
30
30
|
- lib/fibon/version.rb
|
31
31
|
- lib/fibon/version.rb~
|
32
|
+
- lib/main.rb~
|
32
33
|
homepage: https://github.com/michaeljacoby/Fibonacci
|
33
34
|
licenses: []
|
34
35
|
post_install_message:
|