Skip to content

Instantly share code, notes, and snippets.

@travisvalentine
Last active January 3, 2016 22:59
Show Gist options
  • Save travisvalentine/8532220 to your computer and use it in GitHub Desktop.
Save travisvalentine/8532220 to your computer and use it in GitHub Desktop.
Scala Project Euler #2
import scala.collection.mutable.MutableList
var a = MutableList(1,2)
var upto = 4000000
while(a(a.size - 2) + a(a.size - 1) < upto) {
a += (a(a.size - 2) + a(a.size - 1))
}
var sum = 0
a.foreach(x => { if(x % 2 == 0) sum += x } )
println(sum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment