numb 0.7.0 → 0.8.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 CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.8.0
@@ -0,0 +1,10 @@
1
+ class Integer
2
+ def balanced_prime?
3
+ return false unless prime? and self >= 5
4
+ primes, before = Prime.each, 2
5
+ primes.each do |prime|
6
+ return ((before + primes.next) / 2) == self if prime == self
7
+ before = prime
8
+ end
9
+ end
10
+ end
data/lib/numb.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- libs = %w{abundant achilles automorphic carol composite deficient
3
+ libs = %w{abundant achilles automorphic balanced_prime carol composite deficient
4
4
  dihedral_prime dudeney economical emrip equidigital
5
5
  extravagant factorion frugal happy harshad hilbert hyperperfect
6
6
  impolite kaprekar keith kynea lucas lucas_carmichael mms_pair mobius
@@ -0,0 +1,15 @@
1
+ describe Integer, "#balanced_prime?" do
2
+ BP = [5,53,157,173,211,257,263,373,563,593,607,653,733,
3
+ 947,977,1103,1123,1187,1223,1367,1511,1747,1753,
4
+ 1907,2287,2417,2677,2903,2963,3307,3313,3637,3733,
5
+ 4013,4409,4457,4597,4657,4691,4993,5107,5113,5303,
6
+ 5387,5393]
7
+
8
+ it "returns true for balanced primes" do
9
+ BP.each{|n| n.should be_balanced_prime}
10
+ end
11
+
12
+ it "returns false for integers which are not balanced primes" do
13
+ ([*1..BP.max] - BP).each{|n| n.should_not be_balanced_prime}
14
+ end
15
+ 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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Run Paint Run Run
@@ -42,6 +42,7 @@ files:
42
42
  - lib/numb/abundant.rb
43
43
  - lib/numb/achilles.rb
44
44
  - lib/numb/automorphic.rb
45
+ - lib/numb/balanced_prime.rb
45
46
  - lib/numb/carol.rb
46
47
  - lib/numb/composite.rb
47
48
  - lib/numb/deficient.rb
@@ -97,6 +98,7 @@ files:
97
98
  - spec/abundant_spec.rb
98
99
  - spec/achilles_spec.rb
99
100
  - spec/automorphic_spec.rb
101
+ - spec/balanced_prime_spec.rb
100
102
  - spec/carol_spec.rb
101
103
  - spec/composite_spec.rb
102
104
  - spec/deficient_spec.rb
@@ -225,6 +227,7 @@ test_files:
225
227
  - spec/powerful_spec.rb
226
228
  - spec/weird_spec.rb
227
229
  - spec/number_of_distinct_prime_factors_spec.rb
230
+ - spec/balanced_prime_spec.rb
228
231
  - spec/digital_sum_spec.rb
229
232
  - spec/factorion_spec.rb
230
233
  - spec/undulating_spec.rb