Created
May 26, 2011 05:27
-
-
Save johana-star/992604 to your computer and use it in GitHub Desktop.
Euler Project Problem #001
This file contains hidden or 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
# Solution to Project Euler's first problem | |
# http://projecteuler.net/index.php?section=problems&id=1 | |
# Sum all numbers divisible by 3 or 5 below 1000. | |
sum = 0 | |
1.upto(999) do |n| | |
if (n % 3 == 0 || n % 5 == 0) then | |
sum = sum + n | |
end | |
end | |
p sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment