Skip to content

Instantly share code, notes, and snippets.

@fhereduardo90
Last active August 29, 2015 14:11
Show Gist options
  • Save fhereduardo90/86306e0c179bdd77045c to your computer and use it in GitHub Desktop.
Save fhereduardo90/86306e0c179bdd77045c to your computer and use it in GitHub Desktop.
Perfect Number
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