Skip to content

Commit

Permalink
Integer#σ∞: Add
Browse files Browse the repository at this point in the history
  • Loading branch information
runpaint committed Mar 19, 2010
1 parent 63d63fb commit 697fdef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/numb/sum_of_infinitary_divisors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# coding: utf-8
class Integer
def σ∞
infinitary_divisors.reduce :+
end

alias :sum_of_infinitary_divisors :σ∞
alias :isigma :σ∞
end
15 changes: 15 additions & 0 deletions spec/sum_of_infinitary_divisors_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# coding: utf-8
describe Integer, "#σ∞" do
# A049417
@seq = [1,3,4,5,6,12,8,15,10,18,12,20,14,24,24,17,18,30,
20,30,32,36,24,60,26,42,40,40,30,72,32,51,48,54,
48,50,38,60,56,90,42,96,44,60,60,72,48,68,50,78,
72,70,54,120,72,120,80,90,60,120,62,96,80,85,84,
144,68,90]

@seq.to_enum.with_index(1).each do |sum, n|
it "returns #{sum} for #{n}" do
n.σ∞.should == sum
end
end
end

0 comments on commit 697fdef

Please sign in to comment.