Created
July 30, 2010 15:05
-
-
Save vito/500674 to your computer and use it in GitHub Desktop.
Project Euler solutions in The
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
problem-1: max = { | |
(0 ... max) | |
(filter: { n | 3 divides?: n || 5 divides?: n }) | |
sum | |
} do | |
(problem-1: 1000) print |
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
problem-2: max = { | |
sum = 0 | |
n0 = 0 | |
n1 = 1 | |
while: { n1 < max } | |
do: { | |
{-sum = sum + (if: n1 even? then: { n1 } else: { 0 })-} | |
-- OR: | |
(b: Block) in-scope = { b scope do: b } | |
when: n1 even? | |
do: { sum = sum + n1 } in-scope | |
n1 = n1 + n0 | |
n0 = n1 - n0 | |
} | |
sum | |
} do | |
(problem-2: 4000000) print |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment