Created
June 13, 2010 16:39
-
-
Save ichyo/436793 to your computer and use it in GitHub Desktop.
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
=begin | |
prime = Array.new | |
count = 1 | |
prime[0] = 2 | |
prime[1] = 3 | |
no = 5 | |
sum = 5 | |
while no<2000000 | |
for i in (1..count) | |
break if (no % prime[i] == 0) | |
end | |
if (i == count) | |
count += 1 | |
prime[count] = no | |
sum += no | |
end | |
no += 2 | |
print no,"\n" | |
end | |
print sum | |
=end | |
sum = 5 | |
no = 5 | |
while no <2000000 | |
i = 3 | |
until i*i>no | |
break if (no%i) | |
i+=2 | |
end | |
sum += no if (i*i>no) | |
no += 2 | |
print no, "\n" | |
end | |
print sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment