Skip to content

Commit

Permalink
start learnin some scala
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmichihara committed Oct 17, 2013
1 parent 728994e commit bf3f290
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
.DS_Store

# IntelliJ
.idea/
out/
*.iml
5 changes: 5 additions & 0 deletions scala/src/P001.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object P001 {
def main(args: Array[String]) {
println((1 to 999).filter(x => x % 3 == 0 || x % 5 == 0).sum)
}
}
6 changes: 6 additions & 0 deletions scala/src/P002.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object P002 {
def main(args: Array[String]) {
lazy val fibs: Stream[BigInt] = BigInt(1) #:: BigInt(2) #:: fibs.zip(fibs.tail).map { n => n._1 + n._2 }
println(fibs.takeWhile(_ < 4000001).filter { _ % 2 == 0 }.sum)
}
}

0 comments on commit bf3f290

Please sign in to comment.