numb 0.9.0 → 0.10.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.9.0
1
+ 0.10.0
@@ -0,0 +1,6 @@
1
+ class Integer
2
+ def rhonda?(base=10)
3
+ d = base == 10 ? digits : to_s(base).split(//).map{|_| _.to_i(base)}
4
+ d.reduce(:*) == base * (prime_factors.reduce(:+) || 0)
5
+ end
6
+ end
data/lib/numb.rb CHANGED
@@ -6,7 +6,7 @@ libs = %w{abundant achilles automorphic balanced_prime carol composite deficient
6
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 primitive_pseudoperfect
9
- pronic self self_descriptive semiperfect semiprime
9
+ pronic rhonda self self_descriptive semiperfect semiprime
10
10
  smarandache_wellin smith sophie_germain_prime sphenic square
11
11
  square_free triangular trimorphic undulating vampire weird
12
12
  }
@@ -0,0 +1,75 @@
1
+ TRIES = 3
2
+ RHONDA = {
3
+ # A100975
4
+ 16 => [1000,1134,6776,15912,19624,20043,20355,23946,
5
+ 26296,29070,31906,32292,34236,34521,36465,39066,
6
+ 50055,50986,52341,54340,58088,59541,75867,85870,
7
+ 87150,88182,93058,95944,99674,101460,109650,
8
+ 109810,119480,124500],
9
+ # A100974
10
+ 15 => [2392,2472,11468,15873,17424,18126,19152,20079,
11
+ 24388,30758,31150,33004,33550,37925,39483,42550,
12
+ 44714,58870,59605,66950,70182,71485,71709,85557,
13
+ 85848,86241,86591,92150,110334,112671,113300,
14
+ 116270,120414],
15
+ # A100972
16
+ 14 => [11475,18655,20565,29631,31725,45387,58404,58667,
17
+ 59950,63945,67525,68904,91245,99603,125543,135196,
18
+ 141141,148645,149575,168270,175577,204611,207230,
19
+ 237540,240006,240787,275429,287950,321867,338709,
20
+ 358984],
21
+ # A100971
22
+ 12 => [560,800,3993,4425,4602,4888,7315,8296,9315,11849,
23
+ 12028,13034,14828,15052,16264,18511,18906,25619,
24
+ 25875,27176,32742,37264,37523,46035,50765,52338,
25
+ 58261,58504,59166,62002,66176,66752,66928,67195,
26
+ 68502],
27
+ # A099542
28
+ 10 => [1568,2835,4752,5265,5439,5664,5824,5832,8526,
29
+ 12985,15625,15698,19435,25284,25662,33475,34935,
30
+ 35581,45951,47265,47594,52374,53176,53742,54479,
31
+ 55272,56356,56718,95232,118465,133857,148653,
32
+ 154462,161785],
33
+ # A100973
34
+ 9 => [15540,21054,25331,44360,44660,44733,47652,50560,
35
+ 54944,76857,77142,83334,83694,96448,97944,106575,
36
+ 108273,117624,125952,138966,141204,144236,153318,
37
+ 158417,159424,188529,188598,189350,192000,192126,
38
+ 196652],
39
+ # A100970
40
+ 8 => [1836,6318,6622,10530,14500,14739,17655,18550,
41
+ 25398,25956,30562,39215,39325,50875,51429,52887,
42
+ 55611,56420,58548,59731,60604,72358,74620,76581,
43
+ 78780,81370,84180,85949,103350,103788,108750,
44
+ 112914,118233],
45
+ # A100969
46
+ 6 => [855,1029,3813,5577,7040,7304,15104,19136,35350,
47
+ 36992,41031,42009,60368,65536,67821,76880,84525,
48
+ 90601,122831,131175,154570,162565,184009,184585,
49
+ 196504,217021,219830,222200,252161,256041,268677,
50
+ 353115,355737]
51
+ }
52
+
53
+ RHONDA.each do |base, members|
54
+ describe Integer, "#rhonda?(#{base})" do
55
+ it "returns true for a Rhonda number in base #{base}" do
56
+ members.shuffle.first(TRIES).each{|_| _.rhonda?(base).should be_true}
57
+ end
58
+
59
+ it "returns false for a non-Rhonda number in base #{base}" do
60
+ ((1..members.max).to_a - members).shuffle.first(TRIES).
61
+ each{|_| _.rhonda?(base).should be_false}
62
+ end
63
+ end
64
+ end
65
+
66
+ describe Integer, "#rhonda?" do
67
+ it "returns true for a Rhonda number in base 10" do
68
+ RHONDA[10].shuffle.first(TRIES).each{|_| _.should be_rhonda}
69
+ end
70
+
71
+ it "returns false for a non-Rhonda number in base 10" do
72
+ ((1..RHONDA[10].max).to_a - RHONDA[10]).shuffle.first(TRIES).
73
+ each{|_| _.should_not be_rhonda}
74
+ end
75
+ 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.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Run Paint Run Run
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-03 00:00:00 +00:00
12
+ date: 2010-01-04 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -79,6 +79,7 @@ files:
79
79
  - lib/numb/prime.rb
80
80
  - lib/numb/primitive_pseudoperfect.rb
81
81
  - lib/numb/pronic.rb
82
+ - lib/numb/rhonda.rb
82
83
  - lib/numb/ruby1.8.rb
83
84
  - lib/numb/ruby1.9.rb
84
85
  - lib/numb/self.rb
@@ -139,6 +140,7 @@ files:
139
140
  - spec/practical_spec.rb
140
141
  - spec/primitive_pseudoperfect_spec.rb
141
142
  - spec/pronic_spec.rb
143
+ - spec/rhonda_spec.rb
142
144
  - spec/self_descriptive_spec.rb
143
145
  - spec/self_spec.rb
144
146
  - spec/semi_perfect_spec.rb
@@ -210,6 +212,7 @@ test_files:
210
212
  - spec/dihedral_prime_spec.rb
211
213
  - spec/sphenic_spec.rb
212
214
  - spec/lucas_carmichael_spec.rb
215
+ - spec/rhonda_spec.rb
213
216
  - spec/composite_spec.rb
214
217
  - spec/practical_spec.rb
215
218
  - spec/sophie_germain_prime_spec.rb