Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def check_abundant(x)
- total(x) > x
- end
- def total (x)
- sum = 1
- (2..Math.sqrt(x)).each do |i|
- sum = sum + x + x/i if x%i == 0 && i != Math.sqrt(x)
- end
- sum
- end
- def non_abundant_sums
- abundant_arr = []
- s = 0
- (12..28123).each do |x|
- if check_abundant(x)
- abundant_arr << x
- end
- end
- (1..28123).each do |x|
- s = s + x unless abundant_arr.include? (total(x) - x)
- end
- s
- end
- puts non_abundant_sums
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement