Skip to content

Instantly share code, notes, and snippets.

@tyamagu2
Last active August 29, 2015 14:22
Show Gist options
  • Save tyamagu2/2ba70c79d7cece4e3a0b to your computer and use it in GitHub Desktop.
Save tyamagu2/2ba70c79d7cece4e3a0b to your computer and use it in GitHub Desktop.
project_euler
-- 1. Find the sum of all the multiples of 3 or 5 below 1000.
sum [ x | x <- [1..999], x `mod` 3 == 0 || x `mod` 5 == 0 ]
-- 2. By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
let p2 = sum [ x | x <- takeWhile (< 4000000) fibs, even x] where fibs = 1 : 2 : zipWith (+) fibs (tail fibs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment