Created
May 6, 2013 18:09
-
-
Save charlesponti/5526924 to your computer and use it in GitHub Desktop.
Project Euler: Problem 10
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
def is_prime?(num) | |
2.upto(num-1) { |i| return false if ((num % i) == 0) } | |
true | |
end | |
def sum_primes(max) | |
sum = 0 | |
2.upto(max-1) { |i| sum += i if is_prime?(i) } | |
p sum | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment