Last active
August 29, 2015 14:11
-
-
Save fhereduardo90/86306e0c179bdd77045c to your computer and use it in GitHub Desktop.
Perfect Number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Perfection | |
def self.instance() @instance ||= Perfection.new end | |
def is_perfect?(candidate) | |
candidate == (1...candidate).to_a.collect{|i| i if (candidate % i) == 0}.compact.inject(:+) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment