Last active
December 16, 2015 11:29
-
-
Save nephilim/5428120 to your computer and use it in GitHub Desktop.
Project Euler 01: Multiples of 3 and 5
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
package ysl.p01 | |
object Multiples extends App{ | |
val naturalNumber: Stream[Int] = Stream.cons(1, naturalNumber.map(_ + 1)) | |
val filtered = naturalNumber.filter(x => (x % 3 == 0 || x % 5 == 0)) | |
println(filtered.takeWhile(_ < 1000).sum) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment