Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Fixnum
- def amicable?
- b = self.divisors.sum
- return b != self && b.divisors.sum == self
- end
- def divisors
- (1..self/2).select{|x| self % x == 0}
- end
- end
- class Array
- def sum
- self.inject(0, &:+)
- end
- end
- (1..10000).select(&:amicable?).sum
Add Comment
Please, Sign In to add comment