2010-06-02から1日間の記事一覧

ScalaでProjectEuler 1 to 10

#!/usr/bin/scala !# { println((0 to 999 toList).filter(s => (s%3==0 || s%5==0)).foldLeft(0)((a,b)=>a+b)) } { def f(x:Int,y:Int,s:Int):Int = if (x <= 4000000) f(y,x+y,x*(1-x%2) + s) else s println(f(1,2,0)) } { def f(n:Long,x:Long):Long = i…