for n in (1 .. 2**19) { var frac = 0 n.divisors.each {|d| frac += 1/d } if (frac.is_int) { say "Sum of reciprocal divisors of #{n} = #{frac} exactly #{ frac == 2 ? '- perfect!' : '' }" } }