numb 0.89.0 → 0.96.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.89.0
1
+ 0.96.0
@@ -0,0 +1,5 @@
1
+ class Integer
2
+ def doubly_even?
3
+ modulo(4).zero?
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class Integer
2
+ def hamming?
3
+ smooth?(5)
4
+ end
5
+ alias :regular? :hamming?
6
+ end
@@ -0,0 +1,10 @@
1
+ class Integer
2
+ def perrin?
3
+ return true if (perin = [3, 0, 2]).include?(self)
4
+ until perin.last > self
5
+ perin << perin[-2] + perin[-3]
6
+ return true if perin.last == self
7
+ end
8
+ false
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class Integer
2
+ def singly_even?
3
+ modulo(4) == 2
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Integer
2
+ def square_triangular?
3
+ square? and triangular?
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Integer
2
+ def squared_triangular?
3
+ square? and Math.sqrt(self).to_i.triangular?
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Integer
2
+ def super_poulet?
3
+ poulet? and divisors.all?{|d| ((2**d) - 2).divides?(d)}
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ describe Integer, "#doubly_even?" do
2
+ # A008586
3
+ @seq = [0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,
4
+ 68,72,76,80,84,88,92,96,100,104,108,112,116,120,
5
+ 124,128,132,136,140,144,148,152,156,160,164,168,
6
+ 172,176,180,184]
7
+
8
+ @seq.each do |n|
9
+ it "returns true for doubly-even number #{n}" do
10
+ n.should be_doubly_even
11
+ end
12
+ end
13
+
14
+ @seq.to_seq.invert.each do |n|
15
+ it "returns false for non-doubly-even number #{n}" do
16
+ n.should_not be_doubly_even
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ describe Integer, "#hamming?" do
2
+ # A051037
3
+ @seq = [1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,
4
+ 36,40,45,48,50,54,60,64,72,75,80,81,90,96,100,108,
5
+ 120,125,128,135,144,150,160,162,180,192,200,216,
6
+ 225,240,243,250,256,270,288,300,320,324,360,375,
7
+ 384,400,405]
8
+
9
+ @seq.each do |n|
10
+ it "returns true for Hamming number #{n}" do
11
+ n.should be_hamming
12
+ end
13
+ end
14
+
15
+ @seq.to_seq.invert.sample(100).each do |n|
16
+ it "returns false for non-Hamming number #{n}" do
17
+ n.should_not be_hamming
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ describe Integer, "#perrin?" do
2
+ # A001608
3
+ @seq = [3,0,2,3,2,5,5,7,10,12,17,22,29,39,51,68,90,119,
4
+ 158,209,277,367,486,644,853,1130,1497,1983,2627,
5
+ 3480,4610,6107,8090,10717,14197,18807,24914,33004,
6
+ 43721,57918,76725,101639,134643,178364,236282,
7
+ 313007]
8
+
9
+ @seq.each do |n|
10
+ it "returns true for Perrin number #{n}" do
11
+ n.should be_perrin
12
+ end
13
+ end
14
+
15
+ @seq.to_seq.invert.sample(100).each do |n|
16
+ it "returns false for non-Perrin number #{n}" do
17
+ n.should_not be_perrin
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ describe Integer, "#singly_even?" do
2
+ # A016825
3
+ @seq = [2,6,10,14,18,22,26,30,34,38,42,46,50,54,58,62,66,
4
+ 70,74,78,82,86,90,94,98,102,106,110,114,118,122,
5
+ 126,130,134,138,142,146,150,154,158,162,166,170,
6
+ 174,178,182,186,190,194,198,202,206,210,214,218,
7
+ 222,226,230,234]
8
+
9
+ @seq.each do |n|
10
+ it "returns true for singly-even number #{n}" do
11
+ n.should be_singly_even
12
+ end
13
+ end
14
+
15
+ @seq.to_seq.invert.each do |n|
16
+ it "returns false for non-singly-even number #{n}" do
17
+ n.should_not be_singly_even
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ describe Integer, "#square_triangular?" do
2
+ # A001110
3
+ @seq = [0,1,36,1225,41616,1413721,48024900,1631432881,
4
+ 55420693056,1882672131025,63955431761796,
5
+ 2172602007770041,73804512832419600,
6
+ 2507180834294496361,85170343853180456676,
7
+ 2893284510173841030625]
8
+
9
+ @seq.each do |n|
10
+ it "returns true for square triangular number #{n}" do
11
+ n.should be_square_triangular
12
+ end
13
+ end
14
+
15
+ @seq.to_seq.invert.sample(100).each do |n|
16
+ it "returns false for non-square-triangular number #{n}" do
17
+ n.should_not be_square_triangular
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ describe Integer, "#squared_triangular?" do
2
+ # A000537
3
+ @seq = [0,1,9,36,100,225,441,784,1296,2025,3025,4356,
4
+ 6084,8281,11025,14400,18496,23409,29241,36100,
5
+ 44100,53361,64009,76176,90000,105625,123201,
6
+ 142884,164836,189225,216225,246016,278784,314721,
7
+ 354025]
8
+
9
+ @seq.each do |n|
10
+ it "returns true for squared triangular number #{n}" do
11
+ n.should be_squared_triangular
12
+ end
13
+ end
14
+
15
+ @seq.to_seq.invert.sample(100).each do |n|
16
+ it "returns false for non-squared-triangular number #{n}" do
17
+ n.should_not be_squared_triangular
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ describe Integer, "#super_poulet?" do
2
+ # A050217
3
+ @seq = [341,1387,2047,2701,3277,4033,4369,4681,5461,7957,
4
+ 8321,10261,13747,14491,15709,18721,19951,23377,
5
+ 31417,31609,31621,35333,42799,49141,49981,60701,
6
+ 60787,65077,65281,80581,83333,85489,88357,90751]
7
+
8
+ @seq.each do |n|
9
+ it "returns true for super-Poulet number #{n}" do
10
+ n.should be_super_poulet
11
+ end
12
+ end
13
+
14
+ @seq.to_seq.invert.sample(100).each do |n|
15
+ it "returns false for non-super-Poulet number #{n}" do
16
+ n.should_not be_super_poulet
17
+ end
18
+ end
19
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
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.89.0
4
+ version: 0.96.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Run Paint Run Run
@@ -71,6 +71,7 @@ files:
71
71
  - lib/numb/deficient.rb
72
72
  - lib/numb/dihedral_prime.rb
73
73
  - lib/numb/dodecagonal.rb
74
+ - lib/numb/doubly_even.rb
74
75
  - lib/numb/dudeney.rb
75
76
  - lib/numb/economical.rb
76
77
  - lib/numb/emrip.rb
@@ -84,6 +85,7 @@ files:
84
85
  - lib/numb/friendly.rb
85
86
  - lib/numb/frugal.rb
86
87
  - lib/numb/goldbach.rb
88
+ - lib/numb/hamming.rb
87
89
  - lib/numb/happy.rb
88
90
  - lib/numb/harshad.rb
89
91
  - lib/numb/heptagonal.rb
@@ -127,6 +129,7 @@ files:
127
129
  - lib/numb/pentagonal.rb
128
130
  - lib/numb/perfect.rb
129
131
  - lib/numb/perfect_power.rb
132
+ - lib/numb/perrin.rb
130
133
  - lib/numb/polite.rb
131
134
  - lib/numb/polydivisible.rb
132
135
  - lib/numb/positive.rb
@@ -149,6 +152,7 @@ files:
149
152
  - lib/numb/self_descriptive.rb
150
153
  - lib/numb/semiperfect.rb
151
154
  - lib/numb/semiprime.rb
155
+ - lib/numb/singly_even.rb
152
156
  - lib/numb/smarandache_wellin.rb
153
157
  - lib/numb/smith.rb
154
158
  - lib/numb/smooth.rb
@@ -157,10 +161,13 @@ files:
157
161
  - lib/numb/sphenic.rb
158
162
  - lib/numb/square.rb
159
163
  - lib/numb/square_free.rb
164
+ - lib/numb/square_triangular.rb
165
+ - lib/numb/squared_triangular.rb
160
166
  - "lib/numb/st\xC3\xB8rmer.rb"
161
167
  - lib/numb/sublime.rb
162
168
  - lib/numb/sum_of_squares.rb
163
169
  - lib/numb/sum_of_unitary_divisors.rb
170
+ - lib/numb/super_poulet.rb
164
171
  - lib/numb/superabundant.rb
165
172
  - lib/numb/superperfect.rb
166
173
  - lib/numb/totient.rb
@@ -213,6 +220,7 @@ files:
213
220
  - spec/numb/dihedral_prime_spec.rb
214
221
  - spec/numb/divides_spec.rb
215
222
  - spec/numb/dodecagonal_spec.rb
223
+ - spec/numb/doubly_even_spec.rb
216
224
  - spec/numb/dudeney_spec.rb
217
225
  - spec/numb/economical_spec.rb
218
226
  - spec/numb/emrip_spec.rb
@@ -226,6 +234,7 @@ files:
226
234
  - spec/numb/friendly_spec.rb
227
235
  - spec/numb/frugal_spec.rb
228
236
  - spec/numb/goldbach_spec.rb
237
+ - spec/numb/hamming_spec.rb
229
238
  - spec/numb/happy_spec.rb
230
239
  - spec/numb/harshad_spec.rb
231
240
  - spec/numb/heptagonal_spec.rb
@@ -267,6 +276,7 @@ files:
267
276
  - spec/numb/pentagonal_spec.rb
268
277
  - spec/numb/perfect_power_spec.rb
269
278
  - spec/numb/perfect_spec.rb
279
+ - spec/numb/perrin_spec.rb
270
280
  - spec/numb/polite_spec.rb
271
281
  - spec/numb/politeness_spec.rb
272
282
  - spec/numb/polydivisible_spec.rb
@@ -290,6 +300,7 @@ files:
290
300
  - spec/numb/self_spec.rb
291
301
  - spec/numb/semi_perfect_spec.rb
292
302
  - spec/numb/semiprime_spec.rb
303
+ - spec/numb/singly_even_spec.rb
293
304
  - spec/numb/smarandache_wellin_spec.rb
294
305
  - spec/numb/smith_spec.rb
295
306
  - spec/numb/smooth_spec.rb
@@ -298,10 +309,13 @@ files:
298
309
  - spec/numb/sphenic_spec.rb
299
310
  - spec/numb/square_free_spec.rb
300
311
  - spec/numb/square_spec.rb
312
+ - spec/numb/square_triangular_spec.rb
313
+ - spec/numb/squared_triangular_spec.rb
301
314
  - "spec/numb/st\xC3\xB8rmer_spec.rb"
302
315
  - spec/numb/sublime_spec.rb
303
316
  - spec/numb/sum_of_squares_spec.rb
304
317
  - spec/numb/sum_of_unitary_divisors_spec.rb
318
+ - spec/numb/super_poulet_spec.rb
305
319
  - spec/numb/superabundant_spec.rb
306
320
  - spec/numb/superperfect_spec.rb
307
321
  - spec/numb/totient_spec.rb
@@ -322,6 +336,7 @@ files:
322
336
  - spec/numb/woodall_spec.rb
323
337
  - spec/numb/zeisel_spec.rb
324
338
  - spec/numb/zerofree_spec.rb
339
+ - spec/spec.opts
325
340
  - spec/spec_helper.rb
326
341
  has_rdoc: yard
327
342
  homepage: http://github.com/runpaint/numb
@@ -387,6 +402,7 @@ test_files:
387
402
  - spec/numb/abundancy_spec.rb
388
403
  - spec/numb/polite_spec.rb
389
404
  - spec/numb/unitary_amicable_spec.rb
405
+ - spec/numb/squared_triangular_spec.rb
390
406
  - spec/numb/zerofree_spec.rb
391
407
  - spec/numb/automorphic_spec.rb
392
408
  - spec/numb/minimal_spec.rb
@@ -407,6 +423,8 @@ test_files:
407
423
  - spec/numb/nth_prime_spec.rb
408
424
  - spec/numb/poulet_spec.rb
409
425
  - spec/numb/congruum_spec.rb
426
+ - spec/numb/hamming_spec.rb
427
+ - spec/numb/doubly_even_spec.rb
410
428
  - spec/numb/safe_prime_spec.rb
411
429
  - spec/numb/sublime_spec.rb
412
430
  - spec/numb/refactorable_spec.rb
@@ -421,6 +439,7 @@ test_files:
421
439
  - spec/numb/sphenic_spec.rb
422
440
  - spec/numb/idoneal_spec.rb
423
441
  - spec/numb/sum_of_unitary_divisors_spec.rb
442
+ - spec/numb/square_triangular_spec.rb
424
443
  - spec/numb/lucas_carmichael_spec.rb
425
444
  - spec/numb/rhonda_spec.rb
426
445
  - spec/numb/totient_spec.rb
@@ -471,6 +490,8 @@ test_files:
471
490
  - spec/numb/binomial_spec.rb
472
491
  - spec/numb/digital_sum_spec.rb
473
492
  - spec/numb/brown_spec.rb
493
+ - spec/numb/perrin_spec.rb
494
+ - spec/numb/super_poulet_spec.rb
474
495
  - spec/numb/factorion_spec.rb
475
496
  - spec/numb/undulating_spec.rb
476
497
  - spec/numb/extravagant_spec.rb
@@ -486,6 +507,7 @@ test_files:
486
507
  - spec/numb/achilles_spec.rb
487
508
  - spec/numb/coprime_spec.rb
488
509
  - spec/numb/almost_prime_spec.rb
510
+ - spec/numb/singly_even_spec.rb
489
511
  - spec/numb/pronic_spec.rb
490
512
  - spec/numb/politeness_spec.rb
491
513
  - spec/numb/noncototient_spec.rb