numb 0.4.0 → 0.5.0
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/VERSION +1 -1
- data/lib/numb/composite.rb +5 -0
- data/lib/numb/lucas_carmichael.rb +8 -0
- data/lib/numb.rb +8 -7
- data/spec/composite_spec.rb +22 -0
- data/spec/lucas_carmichael_spec.rb +14 -0
- metadata +7 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/numb.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
libs = %w{abundant achilles automorphic carol deficient
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
libs = %w{abundant achilles automorphic carol composite deficient
|
4
|
+
dihedral_prime dudeney economical emrip equidigital
|
5
|
+
extravagant factorion frugal happy harshad hilbert hyperperfect
|
6
|
+
impolite kaprekar keith kynea lucas_carmichael mms_pair mobius
|
7
|
+
narcissistic nivenmorphic ordinal parasitic perfect perfect_power
|
8
|
+
polite polydivisible powerful practical pronic self self_descriptive
|
9
|
+
semi_perfect semiprime smarandache_wellin smith sphenic square
|
10
|
+
square_free triangular trimorphic undulating vampire weird
|
10
11
|
}
|
11
12
|
|
12
13
|
class Integer
|
@@ -0,0 +1,22 @@
|
|
1
|
+
describe Integer, "#composite?" do
|
2
|
+
COMPOSITE = [4,6,8,9,10,12,14,15,16,18,20,21,22,24,25,26,27,
|
3
|
+
28,30,32,33,34,35,36,38,39,40,42,44,45,46,48,49,
|
4
|
+
50,51,52,54,55,56,57,58,60,62,63,64,65,66,68,69,
|
5
|
+
70,72,74,75,76,77,78,80,81,82,84,85,86,87,88]
|
6
|
+
|
7
|
+
it "returns true for composite numbers" do
|
8
|
+
COMPOSITE.each{|n| n.should be_composite}
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns false for non-composite numbers" do
|
12
|
+
((0..88).to_a - COMPOSITE).each{|n| n.should_not be_composite}
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns false for 1" do
|
16
|
+
1.should_not be_composite
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns false for primes" do
|
20
|
+
Prime.first(300).each{|n| n.should_not be_composite}
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
describe Integer, "#lucas_carmichael?" do
|
2
|
+
LC = [399, 935, 2015, 2915, 4991, 5719, 7055, 8855, 12719, 18095,
|
3
|
+
20705, 20999, 22847, 29315, 31535, 46079, 51359, 60059,
|
4
|
+
63503, 67199, 73535, 76751, 80189, 81719, 88559, 90287,
|
5
|
+
104663, 117215, 120581, 147455, 152279, 155819, 162687, 191807]
|
6
|
+
|
7
|
+
it "returns true for Lucas-Carmichael numbers" do
|
8
|
+
LC.each {|n| n.should be_lucas_carmichael}
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns fals for non-Lucas-Carmichael numbers" do
|
12
|
+
[23, 398, 672, 90288, 72621].each {|n| n.should_not be_lucas_carmichael}
|
13
|
+
end
|
14
|
+
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Run Paint Run Run
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- lib/numb/achilles.rb
|
44
44
|
- lib/numb/automorphic.rb
|
45
45
|
- lib/numb/carol.rb
|
46
|
+
- lib/numb/composite.rb
|
46
47
|
- lib/numb/deficient.rb
|
47
48
|
- lib/numb/dihedral_prime.rb
|
48
49
|
- lib/numb/dudeney.rb
|
@@ -60,6 +61,7 @@ files:
|
|
60
61
|
- lib/numb/kaprekar.rb
|
61
62
|
- lib/numb/keith.rb
|
62
63
|
- lib/numb/kynea.rb
|
64
|
+
- lib/numb/lucas_carmichael.rb
|
63
65
|
- lib/numb/mms_pair.rb
|
64
66
|
- lib/numb/mobius.rb
|
65
67
|
- lib/numb/narcissistic.rb
|
@@ -94,6 +96,7 @@ files:
|
|
94
96
|
- spec/achilles_spec.rb
|
95
97
|
- spec/automorphic_spec.rb
|
96
98
|
- spec/carol_spec.rb
|
99
|
+
- spec/composite_spec.rb
|
97
100
|
- spec/deficient_spec.rb
|
98
101
|
- spec/digital_sum_spec.rb
|
99
102
|
- spec/dihedral_prime_spec.rb
|
@@ -112,6 +115,7 @@ files:
|
|
112
115
|
- spec/kaprekar_spec.rb
|
113
116
|
- spec/keith_spec.rb
|
114
117
|
- spec/kynea_spec.rb
|
118
|
+
- spec/lucas_carmichael_spec.rb
|
115
119
|
- spec/maris_mcgwire_sosa_pair_spec.rb
|
116
120
|
- spec/mobius_spec.rb
|
117
121
|
- spec/narcissistic_spec.rb
|
@@ -196,6 +200,8 @@ test_files:
|
|
196
200
|
- spec/vampire_spec.rb
|
197
201
|
- spec/dihedral_prime_spec.rb
|
198
202
|
- spec/sphenic_spec.rb
|
203
|
+
- spec/lucas_carmichael_spec.rb
|
204
|
+
- spec/composite_spec.rb
|
199
205
|
- spec/practical_spec.rb
|
200
206
|
- spec/parasitic_spec.rb
|
201
207
|
- spec/number_of_prime_factors_spec.rb
|