numb 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.20.0
1
+ 0.21.0
@@ -0,0 +1,8 @@
1
+ class Integer
2
+ def fibonacci?
3
+ return true if self == 1
4
+ # Posamentier, Alfred; Lehmann, Ingmar (2007). The (Fabulous) FIBONACCI
5
+ # Numbers. Prometheus Books. pp. 305
6
+ [4, -4].map{|x| (5 * (self**2)) + x}.one? &:square?
7
+ end
8
+ end
data/lib/numb.rb CHANGED
@@ -3,10 +3,10 @@
3
3
  libs = %w{abundant achilles automorphic balanced_prime carmichael carol
4
4
  composite cube decagonal deficient dodecagonal dihedral_prime
5
5
  dudeney economical emrip equidigital extravagant factorion
6
- frugal happy harshad heptagonal hexagonal hilbert hyperperfect
7
- impolite kaprekar keith kynea lucas lucas_carmichael mms_pair
8
- mobius myriagonal narcissistic nivenmorphic n_gonal octagonal
9
- ordinal parasitic pentagonal perfect perfect_power polite
6
+ fibonacci frugal happy harshad heptagonal hexagonal hilbert
7
+ hyperperfect impolite kaprekar keith kynea lucas lucas_carmichael
8
+ mms_pair mobius myriagonal narcissistic nivenmorphic n_gonal
9
+ octagonal ordinal parasitic pentagonal perfect perfect_power polite
10
10
  polydivisible powerful practical primitive_pseudoperfect pronic
11
11
  rhonda self self_descriptive semiperfect semiprime
12
12
  smarandache_wellin smith sophie_germain_prime sphenic square
@@ -0,0 +1,20 @@
1
+ describe Integer, "#fibonacci?" do
2
+ # A000045
3
+ FIBONACCI = [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,
4
+ 1597,2584,4181,6765,10946,17711,28657,46368,75025,
5
+ 121393,196418,317811,514229,832040,1346269,
6
+ 2178309,3524578,5702887,9227465,14930352,24157817,
7
+ 39088169].uniq
8
+
9
+ FIBONACCI.each do |n|
10
+ it "returns true for Fibonacci number #{n}" do
11
+ n.should be_fibonacci
12
+ end
13
+ end
14
+
15
+ ((0..FIBONACCI.last).to_a - FIBONACCI).shuffle.first(10).each do |n|
16
+ it "returns false for non-Fibonacci number #{n}" do
17
+ n.should_not be_fibonacci
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Run Paint Run Run
@@ -57,6 +57,7 @@ files:
57
57
  - lib/numb/equidigital.rb
58
58
  - lib/numb/extravagant.rb
59
59
  - lib/numb/factorion.rb
60
+ - lib/numb/fibonacci.rb
60
61
  - lib/numb/frugal.rb
61
62
  - lib/numb/happy.rb
62
63
  - lib/numb/harshad.rb
@@ -127,6 +128,7 @@ files:
127
128
  - spec/extravagant_spec.rb
128
129
  - spec/factor_spec.rb
129
130
  - spec/factorion_spec.rb
131
+ - spec/fibonacci_spec.rb
130
132
  - spec/frugal_spec.rb
131
133
  - spec/happy_spec.rb
132
134
  - spec/harshad_spec.rb
@@ -246,6 +248,7 @@ test_files:
246
248
  - spec/deficient_spec.rb
247
249
  - spec/happy_spec.rb
248
250
  - spec/hexagonal_spec.rb
251
+ - spec/fibonacci_spec.rb
249
252
  - spec/triangular_spec.rb
250
253
  - spec/semi_perfect_spec.rb
251
254
  - spec/pentagonal_spec.rb