numb 0.5.0 → 0.6.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.5.0
1
+ 0.6.0
data/lib/numb/lucas.rb ADDED
@@ -0,0 +1,9 @@
1
+ class Integer
2
+ def lucas?
3
+ return true if (@@lucas ||= [2,1]).include?(self)
4
+ while @@lucas.last < self
5
+ @@lucas.push(@@lucas[-2] + @@lucas[-1])
6
+ end
7
+ @@lucas.last == self
8
+ end
9
+ end
data/lib/numb.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  libs = %w{abundant achilles automorphic carol composite deficient
4
4
  dihedral_prime dudeney economical emrip equidigital
5
5
  extravagant factorion frugal happy harshad hilbert hyperperfect
6
- impolite kaprekar keith kynea lucas_carmichael mms_pair mobius
6
+ impolite kaprekar keith kynea lucas lucas_carmichael mms_pair mobius
7
7
  narcissistic nivenmorphic ordinal parasitic perfect perfect_power
8
8
  polite polydivisible powerful practical pronic self self_descriptive
9
9
  semi_perfect semiprime smarandache_wellin smith sphenic square
@@ -0,0 +1,18 @@
1
+ describe Integer, "#lucas?" do
2
+ LUCAS = [2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,
3
+ 1364,2207,3571,5778,9349,15127,24476,39603,64079,
4
+ 103682,167761,271443,439204,710647,1149851,
5
+ 1860498,3010349,4870847,7881196,12752043,20633239,
6
+ 33385282]
7
+
8
+ it "returns true for Lucas numbers" do
9
+ LUCAS.each{|n| n.should be_lucas}
10
+ end
11
+
12
+ it "returns false for non-Lucas numbers" do
13
+ (0..10_000).each do |n|
14
+ next if LUCAS.include?(n)
15
+ n.should_not be_lucas
16
+ end
17
+ end
18
+ 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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Run Paint Run Run
@@ -61,6 +61,7 @@ files:
61
61
  - lib/numb/kaprekar.rb
62
62
  - lib/numb/keith.rb
63
63
  - lib/numb/kynea.rb
64
+ - lib/numb/lucas.rb
64
65
  - lib/numb/lucas_carmichael.rb
65
66
  - lib/numb/mms_pair.rb
66
67
  - lib/numb/mobius.rb
@@ -116,6 +117,7 @@ files:
116
117
  - spec/keith_spec.rb
117
118
  - spec/kynea_spec.rb
118
119
  - spec/lucas_carmichael_spec.rb
120
+ - spec/lucas_spec.rb
119
121
  - spec/maris_mcgwire_sosa_pair_spec.rb
120
122
  - spec/mobius_spec.rb
121
123
  - spec/narcissistic_spec.rb
@@ -213,6 +215,7 @@ test_files:
213
215
  - spec/semi_perfect_spec.rb
214
216
  - spec/smarandache_wellin_spec.rb
215
217
  - spec/maris_mcgwire_sosa_pair_spec.rb
218
+ - spec/lucas_spec.rb
216
219
  - spec/trimorphic_spec.rb
217
220
  - spec/harshad_spec.rb
218
221
  - spec/carol_spec.rb