James Edward Gray II wrote: > On Dec 5, 2005, at 9:38 AM, Mike Harris wrote: > >> each_divisor do |i| >> return false if sum-i == self >> end > > > Hmm, does that work? > > I'm not trying to slander your code. I'm actually asking because I > think it's very elegant, if it's also correct. > > You're code removes divisors one-by-one, but what if our divisors > looked something like: > > 1, ..., 50, ..., 100 > > And the total sum was just 50 over the number we're testing? The > order we remove divisors might be significant then. Am I right? > > James Edward Gray II > > > ah, I screwed up and scrambled the problem description inbetween reading it and writing it. My solution only considers subsets of size N-1, where N is the divisor count.