Last active
August 29, 2015 14:22
-
-
Save tyamagu2/bfd0c76bbd78c56c90da to your computer and use it in GitHub Desktop.
project_euler
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
# 1. Find the sum of all the multiples of 3 or 5 below 1000. | |
1..999 |> Enum.filter(&(rem(&1, 3) == 0 || rem(&1, 5) == 0)) |> Enum.reduce(&+/2) | |
# 2. By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. | |
Stream.unfold({1, 2}, fn {n1, n2} -> {n1, {n2, n1 + n2}} end) |> Stream.filter(&(rem(&1, 2) == 0)) |> Enum.take_while(&(&1 < 4000_000)) |> Enum.reduce(&+/2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment