numb 0.170.0 → 0.181.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.170.0
1
+ 0.181.0
@@ -55,4 +55,3 @@ class Integer
55
55
  end
56
56
  memoize :superabundant?
57
57
  end
58
-
data/lib/numb/divisors.rb CHANGED
@@ -102,7 +102,7 @@ class Integer
102
102
  # 81.extravagant? #=> false
103
103
  #
104
104
  def extravagant?
105
- digits.size < prime_division.flatten.reject{|d|d==1}.join.to_i.digits.size
105
+ digits.size < primaries.flatten.reject{|d|d==1}.join.to_i.digits.size
106
106
  end
107
107
 
108
108
  alias :wasteful? :extravagant?
@@ -132,10 +132,13 @@ class Integer
132
132
  end
133
133
  memoize :divisors
134
134
 
135
- def sum_of_divisors
136
- @sod ||= divisors.reduce(:+)
135
+ def sum_of_divisors(k=1)
136
+ (k == 1 ? divisors : divisors.map{|d| d**k}).reduce(:+)
137
137
  end
138
+
138
139
  alias :σ :sum_of_divisors
140
+
141
+ memoize :σ
139
142
 
140
143
  def aliquot_sum
141
144
  return 0 if zero?
@@ -149,7 +152,7 @@ class Integer
149
152
  def σe
150
153
  # TODO: If squarefree, the sum of a number’s e-divisors is the number
151
154
  # itself. Do we gain anything significant by special-casing this?
152
- e_divisors.reduce(:+)
155
+ e_divisors.reduce :+
153
156
  end
154
157
 
155
158
  alias :sum_of_e_divisors :σe
@@ -204,7 +207,7 @@ class Integer
204
207
  # 1287.equidigital? #=> false
205
208
  #
206
209
  def equidigital?
207
- digits.size == prime_division.flatten.reject{|d|d==1}.join.to_i.digits.size
210
+ digits.size == primaries.flatten.reject{|d|d==1}.join.to_i.digits.size
208
211
  end
209
212
 
210
213
  def giuga?
@@ -240,7 +243,7 @@ class Integer
240
243
 
241
244
  def ore?
242
245
  div = divisors
243
- Rational(div.size, div.map{|d| Rational(1, d)}.reduce(:+)).denominator == 1
246
+ Rational(div.size, div.map{|d| d.reciprocal}.reduce(:+)).denominator == 1
244
247
  end
245
248
 
246
249
  alias :harmonic_divisor? :ore?
@@ -276,7 +279,7 @@ class Integer
276
279
 
277
280
  def smith?
278
281
  return false if prime?
279
- digital_sum == prime_division.map{|d,e| d.digital_sum * e}.reduce(:+)
282
+ digital_sum == primaries.map{|d,e| d.digital_sum * e}.reduce(:+)
280
283
  end
281
284
 
282
285
  def smooth?(b)
@@ -345,8 +348,6 @@ class Integer
345
348
  neighbour = ->(e) { (self/e).divisors.reject{|d| d > e} }
346
349
  x, div, exponents = self, divisors, {}
347
350
 
348
- # TODO: Consider using limit's primaries as an upper limit on the
349
- # exponents
350
351
  Prime.each do |b|
351
352
  max_exponent = Math.log(limit, b).floor
352
353
  d = div.reject{|d| d > max_exponent}.sort.reverse - [1]
@@ -386,4 +387,39 @@ class Integer
386
387
  def square_part
387
388
  divisors.sort.reverse.each{|d| return d if d.square?}
388
389
  end
390
+
391
+ def ruler
392
+ (2 * self).primaries.first.last
393
+ end
394
+
395
+ def smarandache
396
+ if self == 1 then 1
397
+ elsif prime? then self
398
+ elsif factorial? then factorial_of?
399
+ elsif primaries.map(&:last).uniq == 1 then primaries.last.first
400
+ elsif primaries.size == 1
401
+ p, k = primaries.first
402
+ return p*k if k < p
403
+ i = k/p
404
+ loop do
405
+ sum = i
406
+ r = i / p
407
+ while r > 0
408
+ sum += r
409
+ r /= p
410
+ end
411
+ return i*p if sum >= k
412
+ i += 1
413
+ end
414
+ else
415
+ primaries.map{|b,e| (b**e).smarandache}.max
416
+ end
417
+ end
418
+
419
+ def ramanujan_tau
420
+ return 1 if (n = self) == 1
421
+ n**4 * n.σ - 24 * (1...n).map do |k|
422
+ k**2 * (35 * k**2 - 52 * k * n + 18 * n**2) * k.σ * (n-k).σ
423
+ end.reduce(:+)
424
+ end
389
425
  end
@@ -14,4 +14,16 @@ class Integer
14
14
  end
15
15
  end
16
16
  end
17
+
18
+ def factorial_of?
19
+ return false unless factorial?
20
+ return 1 if self == 1
21
+ pfacts = primaries
22
+ divisors.sort.take_while.with_index{|d,i| d == i.succ}.reverse_each do |d|
23
+ pfacts.all? do |b, e|
24
+ (1..Math.log(d,b)).map{|k| Rational(d, b**k).floor}.reduce(:+) == e
25
+ end and return d
26
+ end
27
+ nil
28
+ end
17
29
  end
data/lib/numb/figurate.rb CHANGED
@@ -90,7 +90,7 @@ class Integer
90
90
 
91
91
  def pyramidal(r)
92
92
  n = self
93
- (Rational(1, 6) * n * n.succ * (((r - 2) * n) + (5 - r))).to_i
93
+ (6.reciprocal * n * n.succ * (((r - 2) * n) + (5 - r))).to_i
94
94
  end
95
95
 
96
96
  def octahedral
data/lib/numb/mobius.rb CHANGED
@@ -2,9 +2,16 @@
2
2
  class Integer
3
3
  def mobius
4
4
  return if self < 1
5
- ω < Ω ? 0 : (-1)**(Ω)
5
+ ω < Ω ? 0 : liouville
6
6
  end
7
7
 
8
8
  alias :möbius :mobius
9
9
  alias :μ :mobius
10
+
11
+ # TODO: Consider Deléglise and Rivat's "Computing the Summation of the
12
+ # Mőbius Function", Experimental Mathematics, Vol. 5 (1996), No. 4
13
+
14
+ def mertens
15
+ (1..self).map(&:μ).reduce(:+)
16
+ end
10
17
  end
data/lib/numb/primes.rb CHANGED
@@ -151,6 +151,11 @@ class Integer
151
151
  end
152
152
  alias :bigomega :number_of_prime_factors
153
153
  alias :Ω :number_of_prime_factors
154
+ alias :roundness :number_of_prime_factors
155
+
156
+ def liouville
157
+ (-1)**Ω
158
+ end
154
159
 
155
160
  def prime_factors
156
161
  return [] if zero?
@@ -161,4 +166,12 @@ class Integer
161
166
  return false unless prime?
162
167
  (2**(self - 1)).modulo(self ** 2) == 1
163
168
  end
169
+
170
+ def chen_prime?
171
+ prime? and (succ.succ.prime? or succ.succ.semiprime?)
172
+ end
173
+
174
+ def mangoldt
175
+ prime? ? Math.log(prime_factors.first) : 0
176
+ end
164
177
  end
@@ -0,0 +1,19 @@
1
+ # coding: utf-8
2
+ class Integer
3
+ def quadratic_residue?(p)
4
+ residue? p, 2
5
+ end
6
+
7
+ def cubic_residue?(p)
8
+ coprime?(p) and residue? p, 3
9
+ end
10
+
11
+ def reciprocal
12
+ self ** -1
13
+ end
14
+
15
+ private
16
+ def residue?(p, e=1)
17
+ (1...p).any?{|x| (x**e).modulo(p) == self}
18
+ end
19
+ end
data/lib/numb/totient.rb CHANGED
@@ -3,7 +3,7 @@ class Integer
3
3
  def φ
4
4
  return 1 if self == 1
5
5
  return self - 1 if prime?
6
- (prime_factors.uniq.map{|f| 1 - Rational(1, f)}.reduce(:*) * self).to_i
6
+ (prime_factors.uniq.map{|f| 1 - f.reciprocal}.reduce(:*) * self).to_i
7
7
  end
8
8
 
9
9
  alias :totient :φ
@@ -14,7 +14,7 @@ describe Integer, "#bernoulli" do
14
14
  @seq = @numerators.zip(@denominators).map{|n,d| Rational(n,d)}
15
15
  @seq = ([0.to_r] * @numerators.size).zip(@seq).flatten
16
16
  @seq.shift
17
- @seq[1] = -Rational(1, 2)
17
+ @seq[1] = -2.reciprocal
18
18
  @seq.each_with_index do |r, n|
19
19
  it "returns #{r} for #{n}" do
20
20
  n.bernoulli.should == r
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ describe Integer, "#chen_prime?" do
3
+ # A109611
4
+ @seq = [2,3,5,7,11,13,17,19,23,29,31,37,41,47,53,59,67,
5
+ 71,83,89,101,107,109,113,127,131,137,139,149,157,
6
+ 167,179,181,191,197,199,211,227,233,239,251,257,
7
+ 263,269,281,293,307,311,317,337,347,353,359,379,
8
+ 389,401,409]
9
+
10
+ @seq.each do |n|
11
+ it "returns true for Chen prime #{n}" do
12
+ n.should be_chen_prime
13
+ end
14
+ end
15
+
16
+ @seq.to_seq.invert.each do |n|
17
+ it "returns false for non-Chen prime #{n}" do
18
+ n.should_not be_chen_prime
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ describe Integer, "#cubic_residue?" do
3
+ # A096107
4
+ @seq = [
5
+ [1],
6
+ [1,2],
7
+ [1,3],
8
+ [1,2,3,4],
9
+ [1,5],
10
+ [1,6],
11
+ [1,3,5,7],
12
+ [1,8],
13
+ [1,3,7,9],
14
+ [1,2,3,4,5,6,7,8,9,10],
15
+ [1,5,7,11],
16
+ [1,5,8,12],
17
+ [1,13],
18
+ [1,2,4,7,8,11,13,14],
19
+ [1,3,5,7,9,11,13,15],
20
+ [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],
21
+ [1,17],
22
+ [1,7,8,11,12,18],
23
+ [1,3,7,9,11,13,17,19],
24
+ [1,8]
25
+ ]
26
+
27
+ @seq.to_enum.with_index(2).each do |values, p|
28
+ (1...p).each do |n|
29
+ if values.include?(n)
30
+ it "returns true for cubic residue (mod #{p}) #{n}" do
31
+ n.should be_cubic_residue(p)
32
+ end
33
+ elsif p != 21
34
+ it "returns false for cubic non-residue (mod #{p}) #{n}" do
35
+ n.should_not be_cubic_residue(p)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,12 +1,12 @@
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]
1
+ # A000142
2
+ FACTORIAL = [1,1,2,6,24,120,720,5040,40320,362880,3628800,
3
+ 39916800,479001600,6227020800,87178291200,
4
+ 1307674368000,20922789888000,355687428096000,
5
+ 6402373705728000,121645100408832000,
6
+ 2432902008176640000]
8
7
 
9
- @seq.each_with_index do |factorial, n|
8
+ describe Integer, "#factorial" do
9
+ FACTORIAL.each_with_index do |factorial, n|
10
10
  it "should return #{factorial} for #{n}!" do
11
11
  n.factorial.should == factorial
12
12
  end
@@ -14,22 +14,30 @@ describe Integer, "#factorial" do
14
14
  end
15
15
 
16
16
  describe Integer, "#factorial?" do
17
- # A000142
18
- @seq = [1,1,2,6,24,120,720,5040,40320,362880,3628800,
19
- 39916800,479001600,6227020800,87178291200,
20
- 1307674368000,20922789888000,355687428096000,
21
- 6402373705728000,121645100408832000,
22
- 2432902008176640000]
23
-
24
- @seq.first(10).each do |n|
17
+ FACTORIAL.first(10).each do |n|
25
18
  it "should return true for factorial #{n}" do
26
19
  n.should be_factorial
27
20
  end
28
21
  end
29
22
 
30
- @seq.first(10).to_seq.invert.sample(10).each do |n|
23
+ FACTORIAL.first(10).to_seq.invert.sample(10).each do |n|
31
24
  it "should return false for non-factorial #{n}" do
32
25
  n.should_not be_factorial
33
26
  end
34
27
  end
35
28
  end
29
+
30
+ describe Integer, "#factorial_of?" do
31
+ FACTORIAL.first(12).each_with_index do |factorial, n|
32
+ next if n.zero?
33
+ it "should return #{n} for #{factorial}" do
34
+ factorial.factorial_of?.should == n
35
+ end
36
+ end
37
+
38
+ FACTORIAL.first(10).to_seq.invert.sample(10).each do |n|
39
+ it "should return false for non-factorial #{n}" do
40
+ n.factorial_of?.should be_false
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ # coding: utf-8
2
+ describe Integer, "#liouville" do
3
+ # A008836
4
+ @seq = [1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,
5
+ -1,1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,1,-1,1,1,
6
+ 1,-1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,1,1,1,
7
+ -1,1,-1,1,-1,1,1,-1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,
8
+ -1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,1,1,1,1,-1,-1,
9
+ -1,1,-1]
10
+
11
+ @seq.to_enum.with_index(1).each do |l, n|
12
+ it "returns #{l} for #{n}" do
13
+ n.liouville.should == l
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ describe Integer, "#mangoldt" do
3
+ # A029833
4
+ @seq = [0,1,1,0,2,0,2,0,0,0,2,0,3,0,0,0,3,0,3,0,0,0,3,0,
5
+ 0,0,0,0,3,0,3,0,0,0,0,0,4,0,0,0,4,0,4,0,0,0,4,0,0,
6
+ 0,0,0,4,0,0,0,0,0,4,0,4,0,0,0,0,0,4,0,0,0,4,0,4,0,
7
+ 0,0,0,0,4,0]
8
+
9
+ @seq.to_enum.with_index(1).each do |m, n|
10
+ it "returns a value which rounds to #{m} for #{n}" do
11
+ n.mangoldt.round.should == m
12
+ end
13
+ end
14
+
15
+ # A029834
16
+ [0,0,1,0,1,0,1,0,0,0,2,0,2,0,0,0,2,0,2,0,0,0,3,0,
17
+ 0,0,0,0,3,0,3,0,0,0,0,0,3,0,0,0,3,0,3,0,0,0,3,0,0,
18
+ 0,0,0,3,0,0,0,0,0,4,0,4,0,0,0,0,0,4,0,0,0,4,0,4,0,
19
+ 0,0,0,0,4,0].to_enum.with_index(1).each do |m, n|
20
+ it "returns a value which has a floor of #{m} for #{n}" do
21
+ n.mangoldt.floor.should == m
22
+ end
23
+ end
24
+
25
+ # A029832
26
+ [0,1,2,0,2,0,2,0,0,0,3,0,3,0,0,0,3,0,3,0,0,0,4,0,
27
+ 0,0,0,0,4,0,4,0,0,0,0,0,4,0,0,0,4,0,4,0,0,0,4,0,0,
28
+ 0,0,0,4,0,0,0,0,0,5,0,5,0,0,0,0,0,5,0,0,0,5,0,5,0,
29
+ 0,0,0,0,5,0].to_enum.with_index(1).each do |m, n|
30
+ it "returns a value which has a ceiling of #{m} for #{n}" do
31
+ n.mangoldt.ceil.should == m
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,15 @@
1
+ # coding: utf-8
2
+ describe Integer, "#mertens" do
3
+ # A002321
4
+ @seq = [1,0,-1,-1,-2,-1,-2,-2,-2,-1,-2,-2,-3,-2,-1,-1,-2,
5
+ -2,-3,-3,-2,-1,-2,-2,-2,-1,-1,-1,-2,-3,-4,-4,-3,
6
+ -2,-1,-1,-2,-1,0,0,-1,-2,-3,-3,-3,-2,-3,-3,-3,-3,
7
+ -2,-2,-3,-3,-2,-2,-1,0,-1,-1,-2,-1,-1,-1,0,-1,-2,
8
+ -2,-1,-2,-3,-3,-4,-3,-3,-3,-2,-3,-4,-4,-4]
9
+
10
+ @seq.to_enum.with_index(1).each do |m, n|
11
+ it "returns #{m} for #{n}" do
12
+ n.mertens.should == m
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ describe Integer, "#quadratic_residue?" do
3
+ #A046071
4
+ @seq = [
5
+ [1],
6
+ [1],
7
+ [1],
8
+ [1,4],
9
+ [1,3,4],
10
+ [1,2,4],
11
+ [1,4],
12
+ [1,4,7],
13
+ [1,4,5,6,9],
14
+ [1,3,4,5,9],
15
+ [1,4,9],
16
+ [1,3,4,9,10,12],
17
+ [1,2,4,7,8,9,11],
18
+ [1,4,6,9,10],
19
+ [1,4,9],
20
+ [1,2,4,8,9,13,15,16],
21
+ [1,4,7,9,10,13,16],
22
+ [1,4,5,6,7,9,11,16,17],
23
+ [1,4,5,9,16],
24
+ [1,4,7,9,15,16,18],
25
+ [1,3,4,5,9,11,12]
26
+ ]
27
+
28
+ @seq.to_enum.with_index(2).each do |values, p|
29
+ (1...p).each do |n|
30
+ if values.include?(n)
31
+ it "returns true for quadratic residue (mod #{p}) #{n}" do
32
+ n.should be_quadratic_residue(p)
33
+ end
34
+ elsif p != 22
35
+ it "returns false for quadratic non-residue (mod #{p}) #{n}" do
36
+ n.should_not be_quadratic_residue(p)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ describe Integer, "#ramanujan_tau" do
3
+ # A000594
4
+ @seq = [1,-24,252,-1472,4830,-6048,-16744,84480,-113643,
5
+ -115920,534612,-370944,-577738,401856,1217160,
6
+ 987136,-6905934,2727432,10661420,-7109760,
7
+ -4219488,-12830688,18643272,21288960,-25499225,
8
+ 13865712,-73279080,24647168]
9
+
10
+ @seq.to_enum.with_index(1).each do |r, n|
11
+ it "returns #{r} for #{n}" do
12
+ n.ramanujan_tau.should == r
13
+ end
14
+ end
15
+
16
+ # Confirm some arbitrary large(ish) values to confirm we aren't subject to
17
+ # rounding errors
18
+ [[1357, -96743736788237280], [1314, 3992391292945104]].each do |n, r|
19
+ it "returns #{r} for #{n}" do
20
+ n.ramanujan_tau.should == r
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ # coding: utf-8
2
+ describe Integer, "#reciprocal" do
3
+
4
+ 100.times do
5
+ n = rand(10**10)
6
+ redo if n.zero?
7
+ r = Rational(1, n)
8
+ it "returns #{r} as the reciprocal of #{n}" do
9
+ n.reciprocal.should == r
10
+ end
11
+ end
12
+
13
+ it "raises a ZeroDivisionError for the reciprocal of zero" do
14
+ ->{ 0.reciprocal }.should raise_error(ZeroDivisionError)
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ # coding: utf-8
2
+ describe Integer, "#ruler" do
3
+ # A001511
4
+ @seq = [1,2,1,3,1,2,1,4,1,2,1,3,1,2,1,5,1,2,1,3,1,2,1,4,
5
+ 1,2,1,3,1,2,1,6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1,5,1,
6
+ 2,1,3,1,2,1,4,1,2,1,3,1,2,1,7,1,2,1,3,1,2,1,4,1,2,
7
+ 1,3,1,2,1,5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1,6,1,2,1,
8
+ 3,1,2,1,4,1]
9
+
10
+ @seq.to_enum.with_index(1).each do |r, n|
11
+ it "returns #{r} for the ruller function applied to #{n}" do
12
+ n.ruler.should == r
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # coding: utf-8
2
+ describe Integer, "#smarandache" do
3
+ # A002034
4
+ @seq = [1,2,3,4,5,3,7,4,6,5,11,4,13,7,5,6,17,6,19,5,7,11,
5
+ 23,4,10,13,9,7,29,5,31,8,11,17,7,6,37,19,13,5,41,
6
+ 7,43,11,6,23,47,6,14,10,17,13,53,9,11,7,19,29,59,
7
+ 5,61,31,7,8,13,11,67,17,23,7,71,6,73,37,10,19,11,
8
+ 13,79,6,9,41,83,7]
9
+
10
+ @seq.to_enum.with_index(1).each do |s, n|
11
+ it "returns #{s} as the value of the Smarandache function for #{n}" do
12
+ n.smarandache.should == s
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,44 @@
1
+ # coding: utf-8
2
+ describe Integer, "σ" do
3
+
4
+ @seq = {
5
+ # A000005
6
+ 0 => [1,2,2,3,2,4,2,4,3,4,2,6,2,4,4,5,2,6,2,6,4,4,2,8,
7
+ 3,4,4,6,2,8,2,6,4,4,4,9,2,4,4,8,2,8,2,6,6,4,2,10,
8
+ 3,6,4,6,2,8,4,8,4,4,2,12,2,4,6,7,4,8,2,6,4,8,2,12,
9
+ 2,4,6,6,4,8,2,10,5,4,2,12,4,4,4,8,2,12,4,6,4,4,4,
10
+ 12,2,6,6,9,2,8,2,8],
11
+ # A000203
12
+ 1 => [1,3,4,7,6,12,8,15,13,18,12,28,14,24,24,31,18,39,
13
+ 20,42,32,36,24,60,31,42,40,56,30,72,32,63,48,54,
14
+ 48,91,38,60,56,90,42,96,44,84,78,72,48,124,57,93,
15
+ 72,98,54,120,72,120,80,90,60,168,62,96,104,127,84,
16
+ 144,68,126,96,144],
17
+ # A001157
18
+ 2 => [1,5,10,21,26,50,50,85,91,130,122,210,170,250,260,
19
+ 341,290,455,362,546,500,610,530,850,651,850,820,
20
+ 1050,842,1300,962,1365,1220,1450,1300,1911,1370,
21
+ 1810,1700,2210,1682,2500,1850,2562,2366,2650,2210,
22
+ 3410,2451,3255],
23
+ # A001158
24
+ 3 => [1,9,28,73,126,252,344,585,757,1134,1332,2044,
25
+ 2198,3096,3528,4681,4914,6813,6860,9198,9632,
26
+ 11988,12168,16380,15751,19782,20440,25112,24390,
27
+ 31752,29792,37449,37296,44226,43344,55261,50654,
28
+ 61740,61544],
29
+ }
30
+
31
+ @seq.each do |k, values|
32
+ values.to_enum.with_index(1).each do |m, n|
33
+ it "returns #{m} for σ#{k}(#{n})" do
34
+ n.σ(k).should == m
35
+ end
36
+ end
37
+ end
38
+
39
+ @seq[1].to_enum.with_index(1).each do |m, n|
40
+ it "returns #{m} for σ(#{n})" do
41
+ n.σ.should == m
42
+ end
43
+ end
44
+ 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.170.0
4
+ version: 0.181.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-03-26 00:00:00 +00:00
12
+ date: 2010-03-27 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -141,6 +141,7 @@ files:
141
141
  - lib/numb/proth.rb
142
142
  - lib/numb/q.rb
143
143
  - lib/numb/quarticfree.rb
144
+ - lib/numb/reciprocity.rb
144
145
  - lib/numb/refactorable.rb
145
146
  - lib/numb/repunit.rb
146
147
  - lib/numb/reverse.rb
@@ -204,12 +205,14 @@ files:
204
205
  - spec/numb/centered_pentagonal_spec.rb
205
206
  - spec/numb/centered_square_spec.rb
206
207
  - spec/numb/centered_triangular_spec.rb
208
+ - spec/numb/chen_prime_spec.rb
207
209
  - spec/numb/choose_spec.rb
208
210
  - spec/numb/composite_spec.rb
209
211
  - spec/numb/congruum_spec.rb
210
212
  - spec/numb/coprime_spec.rb
211
213
  - spec/numb/core_spec.rb
212
214
  - spec/numb/cube_spec.rb
215
+ - spec/numb/cubic_residue_spec.rb
213
216
  - spec/numb/cullen_spec.rb
214
217
  - spec/numb/cyclic_spec.rb
215
218
  - spec/numb/d_spec.rb
@@ -275,13 +278,16 @@ files:
275
278
  - spec/numb/lah_spec.rb
276
279
  - spec/numb/leonardo_spec.rb
277
280
  - spec/numb/leyland_spec.rb
281
+ - spec/numb/liouville_spec.rb
278
282
  - spec/numb/lucas2_spec.rb
279
283
  - spec/numb/lucas_carmichael_spec.rb
280
284
  - spec/numb/lucas_spec.rb
281
285
  - spec/numb/lychrel_spec.rb
286
+ - spec/numb/mangoldt_spec.rb
282
287
  - spec/numb/maris_mcgwire_sosa_pair_spec.rb
283
288
  - spec/numb/mersenne_prime_spec.rb
284
289
  - spec/numb/mersenne_spec.rb
290
+ - spec/numb/mertens_spec.rb
285
291
  - spec/numb/minimal_spec.rb
286
292
  - spec/numb/mobius_spec.rb
287
293
  - spec/numb/modulo_order_spec.rb
@@ -335,12 +341,16 @@ files:
335
341
  - spec/numb/proth_spec.rb
336
342
  - spec/numb/pyramidal_spec.rb
337
343
  - spec/numb/q_spec.rb
344
+ - spec/numb/quadratic_residue_spec.rb
338
345
  - spec/numb/quarticfree_spec.rb
346
+ - spec/numb/ramanujan_tau_spec.rb
347
+ - spec/numb/reciprocal_spec.rb
339
348
  - spec/numb/refactorable_spec.rb
340
349
  - spec/numb/repunit_spec.rb
341
350
  - spec/numb/reverse_spec.rb
342
351
  - spec/numb/rhonda_spec.rb
343
352
  - spec/numb/rough_spec.rb
353
+ - spec/numb/ruler_spec.rb
344
354
  - spec/numb/safe_prime_spec.rb
345
355
  - "spec/numb/schr\xC3\xB6der_spec.rb"
346
356
  - spec/numb/segmented_spec.rb
@@ -349,6 +359,7 @@ files:
349
359
  - spec/numb/semi_perfect_spec.rb
350
360
  - spec/numb/semiprime_spec.rb
351
361
  - spec/numb/singly_even_spec.rb
362
+ - spec/numb/smarandache_spec.rb
352
363
  - spec/numb/smarandache_wellin_spec.rb
353
364
  - spec/numb/smith_spec.rb
354
365
  - spec/numb/smooth_spec.rb
@@ -368,6 +379,7 @@ files:
368
379
  - "spec/numb/st\xC3\xB8rmer_spec.rb"
369
380
  - spec/numb/subfactorial_spec.rb
370
381
  - spec/numb/sublime_spec.rb
382
+ - spec/numb/sum_of_divisors_spec.rb
371
383
  - spec/numb/sum_of_e_divisors_spec.rb
372
384
  - spec/numb/sum_of_infinitary_divisors_spec.rb
373
385
  - spec/numb/sum_of_squares_spec.rb
@@ -436,11 +448,13 @@ test_files:
436
448
  - spec/numb/proth_spec.rb
437
449
  - spec/numb/stella_octangula_spec.rb
438
450
  - spec/numb/prime_signature_spec.rb
451
+ - spec/numb/reciprocal_spec.rb
439
452
  - spec/numb/mersenne_spec.rb
440
453
  - spec/numb/unitary_divisor_spec.rb
441
454
  - spec/numb/centered_square_spec.rb
442
455
  - spec/numb/primitive_pseudoperfect_spec.rb
443
456
  - spec/numb/polydivisible_spec.rb
457
+ - spec/numb/mangoldt_spec.rb
444
458
  - spec/numb/choose_spec.rb
445
459
  - spec/numb/n_step_fibonacci_spec.rb
446
460
  - spec/numb/sum_of_infinitary_divisors_spec.rb
@@ -467,6 +481,7 @@ test_files:
467
481
  - spec/numb/biquadratic_spec.rb
468
482
  - spec/numb/self_spec.rb
469
483
  - spec/numb/pandigital_spec.rb
484
+ - spec/numb/ruler_spec.rb
470
485
  - spec/numb/square_spec.rb
471
486
  - spec/numb/quarticfree_spec.rb
472
487
  - spec/numb/untouchable_spec.rb
@@ -486,6 +501,7 @@ test_files:
486
501
  - spec/numb/persistent_spec.rb
487
502
  - spec/numb/cullen_spec.rb
488
503
  - spec/numb/palindrome_spec.rb
504
+ - spec/numb/smarandache_spec.rb
489
505
  - spec/numb/zerofree_spec.rb
490
506
  - spec/numb/eban_spec.rb
491
507
  - spec/numb/automorphic_spec.rb
@@ -539,6 +555,7 @@ test_files:
539
555
  - spec/numb/entringer_spec.rb
540
556
  - spec/numb/unitary_sociable_spec.rb
541
557
  - spec/numb/full_reptend_prime_spec.rb
558
+ - spec/numb/quadratic_residue_spec.rb
542
559
  - spec/numb/vampire_spec.rb
543
560
  - spec/numb/tetrahedral_spec.rb
544
561
  - spec/numb/dodecagonal_spec.rb
@@ -554,6 +571,7 @@ test_files:
554
571
  - spec/numb/totient_spec.rb
555
572
  - spec/numb/leyland_spec.rb
556
573
  - spec/numb/mersenne_prime_spec.rb
574
+ - spec/numb/chen_prime_spec.rb
557
575
  - spec/numb/composite_spec.rb
558
576
  - spec/numb/practical_spec.rb
559
577
  - spec/numb/words_spec.rb
@@ -582,9 +600,11 @@ test_files:
582
600
  - spec/numb/hexagonal_spec.rb
583
601
  - spec/numb/nsw_spec.rb
584
602
  - spec/numb/primitive_abundant_spec.rb
603
+ - spec/numb/liouville_spec.rb
585
604
  - spec/numb/lucas2_spec.rb
586
605
  - spec/numb/genocchi_spec.rb
587
606
  - spec/numb/wieferich_prime_spec.rb
607
+ - spec/numb/cubic_residue_spec.rb
588
608
  - spec/numb/fibonacci_spec.rb
589
609
  - spec/numb/triangular_spec.rb
590
610
  - spec/numb/integer_p_spec.rb
@@ -616,6 +636,7 @@ test_files:
616
636
  - spec/numb/weird_spec.rb
617
637
  - spec/numb/interprime_spec.rb
618
638
  - spec/numb/number_of_distinct_prime_factors_spec.rb
639
+ - spec/numb/mertens_spec.rb
619
640
  - spec/numb/catalan_spec.rb
620
641
  - spec/numb/balanced_prime_spec.rb
621
642
  - spec/numb/binomial_spec.rb
@@ -628,11 +649,13 @@ test_files:
628
649
  - spec/numb/super_poulet_spec.rb
629
650
  - spec/numb/sum_of_e_divisors_spec.rb
630
651
  - spec/numb/pyramidal_spec.rb
652
+ - spec/numb/ramanujan_tau_spec.rb
631
653
  - spec/numb/super_d_spec.rb
632
654
  - spec/numb/factorion_spec.rb
633
655
  - spec/numb/lah_spec.rb
634
656
  - spec/numb/undulating_spec.rb
635
657
  - spec/numb/extravagant_spec.rb
658
+ - spec/numb/sum_of_divisors_spec.rb
636
659
  - spec/numb/lychrel_spec.rb
637
660
  - spec/numb/self_descriptive_spec.rb
638
661
  - spec/numb/decagonal_spec.rb