fibon 0.0.3 → 0.0.5

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/README.md CHANGED
@@ -18,7 +18,10 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- The command Fibonacci.place(number) will generate the value at that point in the sequence.
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.
@@ -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
@@ -1,5 +1,31 @@
1
1
  require "fibon/version"
2
2
 
3
3
  module Fibon
4
- # Your code goes here...
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
@@ -1,3 +1,3 @@
1
1
  module Fibon
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module Fibon
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,10 @@
1
+ require './fibon'
2
+
3
+
4
+ x = 0
5
+ while x < 10
6
+ puts x
7
+ puts Fibon.check(x)
8
+
9
+ x = x+1
10
+ end
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.3
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-06 00:00:00.000000000 Z
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: