numb 0.63.0 → 0.68.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.63.0
1
+ 0.68.0
@@ -0,0 +1,5 @@
1
+ class Integer
2
+ def biquadratic?
3
+ (self ** (1.0/4.0)).integer?
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ # coding: utf-8
2
+ class Integer
3
+ def breeder?(b)
4
+ a = self
5
+ x = (a.σ - a).fdiv(b)
6
+ abx = a + (b*x)
7
+ (abx == a.σ) and (abx == b.σ * (x + 1))
8
+ end
9
+ end
data/lib/numb/brown.rb ADDED
@@ -0,0 +1,6 @@
1
+ class Integer
2
+ def brown?(n)
3
+ m = self
4
+ n.factorial.succ == m**2
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class Integer
2
+ def factorial
3
+ return 1 if zero?
4
+ (1..self).reduce(:*)
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class Integer
2
+ def quarticfree?
3
+ self == 1 or prime_signature.max < 4
4
+ end
5
+ alias :biquadratefree? :quarticfree?
6
+ end
data/lib/numb.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  # coding: utf-8
2
2
 
3
3
  libs = %w{abundancy abundant achilles almost_perfect amicable aspiring
4
- automorphic balanced_prime carmichael carol centered_n_gonal
5
- centered_triangular congruum composite coprime core cototient
6
- cube d decagonal deficient dodecagonal dihedral_prime dudeney
7
- economical emrip equidigital extravagant factorion
4
+ automorphic balanced_prime biquadratic breeder brown carmichael carol
5
+ centered_n_gonal centered_triangular congruum composite coprime
6
+ core cototient cube d decagonal deficient dodecagonal dihedral_prime
7
+ dudeney economical emrip equidigital extravagant factorial factorion
8
8
  fermat_pseudoprime fibonacci friendly frugal happy harshad
9
9
  heptagonal hexagonal highly_composite highly_abundant hilbert
10
10
  hyperperfect idoneal impolite integer_p interprime
@@ -14,12 +14,13 @@ libs = %w{abundancy abundant achilles almost_perfect amicable aspiring
14
14
  nivenmorphic noncototient nth_prime number_of_divisors octagonal
15
15
  ordinal ore parasitic pentagonal perfect perfect_power polite
16
16
  polydivisible poulet powerful practical prime_count prime_signature
17
- primitive_pseudoperfect primorial pronic proth refactorable repunit
18
- rhonda rough self self_descriptive semiperfect semiprime
19
- smarandache_wellin smith smooth sophie_germain_prime sphenic square
20
- square_free sublime sum_of_squares superabundant superperfect
21
- totient triangular trimorphic undulating unitary_perfect
22
- unitary_divisor untouchable vampire weird zeisel
17
+ primitive_pseudoperfect primorial pronic proth quarticfree
18
+ refactorable repunit rhonda rough self self_descriptive
19
+ semiperfect semiprime smarandache_wellin smith smooth
20
+ sophie_germain_prime sphenic square square_free sublime
21
+ sum_of_squares superabundant superperfect totient triangular
22
+ trimorphic undulating unitary_perfect unitary_divisor untouchable
23
+ vampire weird zeisel
23
24
  }
24
25
 
25
26
  class Integer
data/spec/01_spec.rb ADDED
@@ -0,0 +1 @@
1
+ require_relative 'spec_helper'
@@ -0,0 +1,20 @@
1
+ describe Integer, "#biquadratic?" do
2
+ # A000583
3
+ @seq = [0,1,16,81,256,625,1296,2401,4096,6561,10000,
4
+ 14641,20736,28561,38416,50625,65536,83521,104976,
5
+ 130321,160000,194481,234256,279841,331776,390625,
6
+ 456976,531441,614656,707281,810000,923521,1048576,
7
+ 1185921].to_seq
8
+
9
+ @seq.each do |n|
10
+ it "should return true for biquadratic number #{n}" do
11
+ n.should be_biquadratic
12
+ end
13
+ end
14
+
15
+ @seq.invert.sample(10).each do |n|
16
+ it "should return false for non-biquadratic number #{n}" do
17
+ n.should_not be_biquadratic
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ describe Integer, "#breeder?" do
2
+ @seq = [
3
+ # Amicable Pairs: A Survery; García, Pedersen, Riele
4
+ [220, 4], [2024, 8], [4981977,13096726199356992193],
5
+ [1001910071475,22707444689738187457315483201],
6
+ ]
7
+
8
+ @seq.first(2).each do |a, b|
9
+ it "should return true for breeder pair (#{a}, #{b})" do
10
+ a.breeder?(b).should be_true
11
+ end
12
+ end
13
+ [[345, 98], [4001, 31], [1110, 2]].each do |a, b|
14
+ it "should return false for non-breeder pair (#{a}, #{b})" do
15
+ a.breeder?(b).should be_false
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ describe Integer, "#brown?" do
2
+ # A163524
3
+ @seq = [5,4,11,5,71,7]
4
+
5
+ @seq.each_slice(2) do |n, m|
6
+ it "should return true for Brown pair (#{n}, #{m})" do
7
+ n.brown?(m).should be_true
8
+ end
9
+
10
+ it "should return false for inverted, non-Brown pair (#{m}, #{n})" do
11
+ m.brown?(n).should be_false
12
+ end
13
+ end
14
+
15
+ @seq.to_seq.invert.sample(10).each_slice(2) do |n, m|
16
+ it "should return false for non-Brown pair (#{n}, #{m})" do
17
+ n.brown?(m).should be_false
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ describe Integer, "#factorial" do
2
+ # A000142
3
+ @seq = [1,1,2,6,24,120,720,5040,40320,362880,3628800,
4
+ 39916800,479001600,6227020800,87178291200,
5
+ 1307674368000,20922789888000,355687428096000,
6
+ 6402373705728000,121645100408832000,
7
+ 2432902008176640000]
8
+
9
+ @seq.each_with_index do |factorial, n|
10
+ it "should return #{factorial} for #{n}!" do
11
+ n.factorial.should == factorial
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,28 @@
1
+ describe Integer, "#quarticfree?" do
2
+ @seq = {
3
+ # A046100
4
+ true => [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,
5
+ 21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,
6
+ 38,39,40,41,42,43,44,45,46,47,49,50,51,52,53,54,
7
+ 55,56,57,58,59,60,61,62,63,65,66,67,68,69,70,71,
8
+ 72,73,74,75,76],
9
+ # A046101
10
+ false => [16,32,48,64,80,81,96,112,128,144,160,162,176,192,
11
+ 208,224,240,243,256,272,288,304,320,324,336,352,
12
+ 368,384,400,405,416,432,448,464,480,486,496,512,
13
+ 528,544,560,567,576,592,608,624,625,640,648,656,
14
+ 672,688,704].to_seq
15
+ }
16
+
17
+ @seq[false].invert.sample(10).each do |n|
18
+ it "should return true for quarticfree number #{n}" do
19
+ n.should be_quarticfree
20
+ end
21
+ end
22
+
23
+ @seq[false].sample(10).each do |n|
24
+ it "should return false for non-quarticfree number #{n}" do
25
+ n.should_not be_quarticfree
26
+ end
27
+ end
28
+ 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.63.0
4
+ version: 0.68.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-14 00:00:00 +00:00
12
+ date: 2010-01-15 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -47,6 +47,9 @@ files:
47
47
  - lib/numb/aspiring.rb
48
48
  - lib/numb/automorphic.rb
49
49
  - lib/numb/balanced_prime.rb
50
+ - lib/numb/biquadratic.rb
51
+ - lib/numb/breeder.rb
52
+ - lib/numb/brown.rb
50
53
  - lib/numb/carmichael.rb
51
54
  - lib/numb/carol.rb
52
55
  - lib/numb/centered_n_gonal.rb
@@ -67,6 +70,7 @@ files:
67
70
  - lib/numb/emrip.rb
68
71
  - lib/numb/equidigital.rb
69
72
  - lib/numb/extravagant.rb
73
+ - lib/numb/factorial.rb
70
74
  - lib/numb/factorion.rb
71
75
  - lib/numb/fermat_pseudoprime.rb
72
76
  - lib/numb/fibonacci.rb
@@ -124,6 +128,7 @@ files:
124
128
  - lib/numb/primorial.rb
125
129
  - lib/numb/pronic.rb
126
130
  - lib/numb/proth.rb
131
+ - lib/numb/quarticfree.rb
127
132
  - lib/numb/refactorable.rb
128
133
  - lib/numb/repunit.rb
129
134
  - lib/numb/rhonda.rb
@@ -153,6 +158,7 @@ files:
153
158
  - lib/numb/vampire.rb
154
159
  - lib/numb/weird.rb
155
160
  - lib/numb/zeisel.rb
161
+ - spec/01_spec.rb
156
162
  - spec/abundancy_spec.rb
157
163
  - spec/abundant_spec.rb
158
164
  - spec/achilles_spec.rb
@@ -161,6 +167,9 @@ files:
161
167
  - spec/aspiring_spec.rb
162
168
  - spec/automorphic_spec.rb
163
169
  - spec/balanced_prime_spec.rb
170
+ - spec/biquadratic_spec.rb
171
+ - spec/breeder_spec.rb
172
+ - spec/brown_spec.rb
164
173
  - spec/carmichael_spec.rb
165
174
  - spec/carol_spec.rb
166
175
  - spec/centered_n_gonal_spec.rb
@@ -182,6 +191,7 @@ files:
182
191
  - spec/emrip_spec.rb
183
192
  - spec/equidigital_spec.rb
184
193
  - spec/extravagant_spec.rb
194
+ - spec/factorial_spec.rb
185
195
  - spec/factorion_spec.rb
186
196
  - spec/fermat_pseudoprime_spec.rb
187
197
  - spec/fibonacci_spec.rb
@@ -238,6 +248,7 @@ files:
238
248
  - spec/primorial_spec.rb
239
249
  - spec/pronic_spec.rb
240
250
  - spec/proth_spec.rb
251
+ - spec/quarticfree_spec.rb
241
252
  - spec/refactorable_spec.rb
242
253
  - spec/repunit_spec.rb
243
254
  - spec/rhonda_spec.rb
@@ -297,6 +308,7 @@ signing_key:
297
308
  specification_version: 3
298
309
  summary: Experiments in number theory with new predicate methods for Integer.
299
310
  test_files:
311
+ - spec/01_spec.rb
300
312
  - spec/leonardo_spec.rb
301
313
  - spec/economical_spec.rb
302
314
  - spec/unitary_perfect.rb
@@ -317,12 +329,15 @@ test_files:
317
329
  - spec/fermat_pseudoprime_spec.rb
318
330
  - spec/abundant_spec.rb
319
331
  - spec/superperfect_spec.rb
332
+ - spec/biquadratic_spec.rb
320
333
  - spec/self_spec.rb
321
334
  - spec/square_spec.rb
335
+ - spec/quarticfree_spec.rb
322
336
  - spec/untouchable_spec.rb
323
337
  - spec/ordinal_spec.rb
324
338
  - spec/perfect_spec.rb
325
339
  - spec/perfect_power_spec.rb
340
+ - spec/factorial_spec.rb
326
341
  - spec/carmichael_spec.rb
327
342
  - spec/abundancy_spec.rb
328
343
  - spec/polite_spec.rb
@@ -351,6 +366,7 @@ test_files:
351
366
  - spec/vampire_spec.rb
352
367
  - spec/dodecagonal_spec.rb
353
368
  - spec/dihedral_prime_spec.rb
369
+ - spec/breeder_spec.rb
354
370
  - spec/sphenic_spec.rb
355
371
  - spec/idoneal_spec.rb
356
372
  - spec/lucas_carmichael_spec.rb
@@ -395,6 +411,7 @@ test_files:
395
411
  - spec/number_of_distinct_prime_factors_spec.rb
396
412
  - spec/balanced_prime_spec.rb
397
413
  - spec/digital_sum_spec.rb
414
+ - spec/brown_spec.rb
398
415
  - spec/factorion_spec.rb
399
416
  - spec/undulating_spec.rb
400
417
  - spec/extravagant_spec.rb