numb 0.109.0 → 0.111.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.109.0
1
+ 0.111.0
@@ -0,0 +1,5 @@
1
+ class Integer
2
+ def beastly?
3
+ to_s.include?('666')
4
+ end
5
+ end
data/lib/numb/bell.rb ADDED
@@ -0,0 +1,16 @@
1
+ class Integer
2
+ def bell?
3
+ triangle = [[1]]
4
+ r = 1
5
+ loop do
6
+ row = [triangle[r - 1][r - 1]]
7
+ (1..r).each do |c|
8
+ row << triangle[r - 1][c - 1] + row[c - 1]
9
+ end
10
+ triangle[r] = row
11
+ return false if row.first > self
12
+ return true if row.first == self
13
+ r += 1
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ describe Integer, "#beastly?" do
2
+ # A051003
3
+ @seq = [666,1666,2666,3666,4666,5666,6660,6661,6662,6663,
4
+ 6664,6665,6666,6667,6668,6669,7666,8666,9666,
5
+ 10666,11666,12666,13666,14666,15666,16660,16661,
6
+ 16662,16663,16664,16665,16666,16667,16668,16669,
7
+ 17666,18666]
8
+
9
+ @seq.each do |n|
10
+ it "returns true for beastly number #{n}" do
11
+ n.should be_beastly
12
+ end
13
+ end
14
+
15
+ @seq.to_seq.invert.sample(100).each do |n|
16
+ it "returns false for non-beastly number #{n}" do
17
+ n.should_not be_beastly
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ describe Integer, "#bell?" do
2
+ # A000110
3
+ @seq = [1,1,2,5,15,52,203,877,4140,21147,115975,678570,
4
+ 4213597,27644437,190899322,1382958545,10480142147,
5
+ 82864869804,682076806159,5832742205057,
6
+ 51724158235372,474869816156751,4506715738447323].uniq
7
+
8
+ @seq.each do |n|
9
+ it "returns true for Bell number #{n}" do
10
+ n.should be_bell
11
+ end
12
+ end
13
+
14
+ @seq.to_seq.invert.sample(100).each do |n|
15
+ it "returns false for non-Bell number #{n}" do
16
+ n.should_not be_bell
17
+ end
18
+ end
19
+ 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.109.0
4
+ version: 0.111.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Run Paint Run Run
@@ -54,6 +54,8 @@ files:
54
54
  - lib/numb/automorphic.rb
55
55
  - lib/numb/balanced_prime.rb
56
56
  - lib/numb/base.rb
57
+ - lib/numb/beastly.rb
58
+ - lib/numb/bell.rb
57
59
  - lib/numb/betrothed.rb
58
60
  - lib/numb/binomial.rb
59
61
  - lib/numb/biquadratic.rb
@@ -215,6 +217,8 @@ files:
215
217
  - spec/numb/automorphic_spec.rb
216
218
  - spec/numb/balanced_prime_spec.rb
217
219
  - spec/numb/base_spec.rb
220
+ - spec/numb/beastly_spec.rb
221
+ - spec/numb/bell_spec.rb
218
222
  - spec/numb/betrothed_spec.rb
219
223
  - spec/numb/binomial_spec.rb
220
224
  - spec/numb/biquadratic_spec.rb
@@ -458,6 +462,7 @@ test_files:
458
462
  - spec/numb/hamming_spec.rb
459
463
  - spec/numb/doubly_even_spec.rb
460
464
  - spec/numb/safe_prime_spec.rb
465
+ - spec/numb/bell_spec.rb
461
466
  - spec/numb/sublime_spec.rb
462
467
  - spec/numb/refactorable_spec.rb
463
468
  - spec/numb/betrothed_spec.rb
@@ -528,6 +533,7 @@ test_files:
528
533
  - spec/numb/digital_sum_spec.rb
529
534
  - spec/numb/brown_spec.rb
530
535
  - spec/numb/perrin_spec.rb
536
+ - spec/numb/beastly_spec.rb
531
537
  - spec/numb/super_poulet_spec.rb
532
538
  - spec/numb/factorion_spec.rb
533
539
  - spec/numb/undulating_spec.rb