numb 0.3.5 → 0.4.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.3.5
1
+ 0.4.0
@@ -0,0 +1,6 @@
1
+ class Integer
2
+ def pronic?
3
+ return false unless even? and self >= 0
4
+ (Math.sqrt(succ).round - Math.sqrt(self).round) == 1
5
+ end
6
+ end
data/lib/numb.rb CHANGED
@@ -4,9 +4,9 @@ libs = %w{abundant achilles automorphic carol deficient dihedral_prime dudeney
4
4
  economical emrip equidigital extravagant factorion frugal happy
5
5
  harshad hilbert hyperperfect impolite kaprekar keith kynea mms_pair mobius
6
6
  narcissistic nivenmorphic ordinal parasitic perfect perfect_power polite
7
- polydivisible powerful practical self self_descriptive semi_perfect semiprime
8
- smarandache_wellin smith sphenic square square_free triangular trimorphic
9
- undulating vampire weird
7
+ polydivisible powerful practical pronic self self_descriptive semi_perfect
8
+ semiprime smarandache_wellin smith sphenic square square_free triangular
9
+ trimorphic undulating vampire weird
10
10
  }
11
11
 
12
12
  class Integer
@@ -0,0 +1,24 @@
1
+ describe Integer, "#pronic?" do
2
+ PRONIC = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210,
3
+ 240, 272, 306, 342, 380, 420, 462, 506, 552, 600, 650, 702,
4
+ 756, 812, 870, 930, 992, 1056, 1122, 1190, 1260, 1332,
5
+ 1406, 1482, 1560, 1640, 1722, 1806, 1892, 1980, 2070,
6
+ 2162, 2256, 2352, 2450, 2550]
7
+ it "returns true if the number is pronic" do
8
+ PRONIC.each do |number|
9
+ number.should be_pronic
10
+ end
11
+ end
12
+
13
+ it "returns false if the number is not pronic" do
14
+ [1, 39, 69, 13791].each do |number|
15
+ number.should_not be_pronic
16
+ end
17
+ end
18
+
19
+ it "returns false if the number is negative" do
20
+ [-1, -70, -39, -19390].each do |number|
21
+ number.should_not be_pronic
22
+ end
23
+ end
24
+ 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.3.5
4
+ version: 0.4.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-01 00:00:00 +00:00
12
+ date: 2010-01-02 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -73,6 +73,7 @@ files:
73
73
  - lib/numb/powerful.rb
74
74
  - lib/numb/practical.rb
75
75
  - lib/numb/prime.rb
76
+ - lib/numb/pronic.rb
76
77
  - lib/numb/ruby1.8.rb
77
78
  - lib/numb/ruby1.9.rb
78
79
  - lib/numb/self.rb
@@ -126,6 +127,7 @@ files:
126
127
  - spec/polydivisible_spec.rb
127
128
  - spec/powerful_spec.rb
128
129
  - spec/practical_spec.rb
130
+ - spec/pronic_spec.rb
129
131
  - spec/self_descriptive_spec.rb
130
132
  - spec/self_spec.rb
131
133
  - spec/semi_perfect_spec.rb
@@ -221,5 +223,6 @@ test_files:
221
223
  - spec/keith_spec.rb
222
224
  - spec/narcissistic_spec.rb
223
225
  - spec/achilles_spec.rb
226
+ - spec/pronic_spec.rb
224
227
  - spec/politeness_spec.rb
225
228
  - spec/mobius_spec.rb