The Project Euler Challenge  Exercise Your Scala Skills  Mitch Wong Ho  9/28/11 6:45 AM  As a fun way to learn Scala and the challenge your self, I've created
an account on The Euler Project (http://projecteuler.net). If you are not aware of Project Euler, Project Euler is a website that "Project Euler exists to encourage, challenge, and develop the skills and enjoyment of anyone with an interest in the fascinating world of mathematics." The idea is to post a problem from Project Euler and you can then work through it and post the solution code here. Have fun! 
unk...@googlegroups.com  9/28/11 6:47 AM  <This message has been deleted.>  
Re: The Project Euler Challenge  Exercise Your Scala Skills  Mitch Wong Ho  9/28/11 6:56 AM  #1 Add all the natural numbers below one thousand that are multiples
of 3 or 5. 
Re: The Project Euler Challenge  Exercise Your Scala Skills  Gary Pamparà  9/28/11 10:09 AM  Just remember that the solutions are supposed to be a secret :) It's an achievement to get them. There are numerous ways to solve this first problem, but two that 1. filter: val x = (1 until 1000) filter { x => x % 3 == 0  x % 5 == 0 } 2. flatMap (using a for comprehension): val y = for { i < (1 until 1000) if (i %3 == 0  i % 5 == 0) } yield i Regards,

Re: The Project Euler Challenge  Exercise Your Scala Skills  Mitch Wong Ho  9/28/11 12:47 PM  In the name of fun and learning, I thought this would be a good way to
learn and apply Scala. Thank you Gary for your two solutions. If you run either of Gary's statements in the interpreter, you get a List of values that multiples of 3 or 5. Just to finish off the solution and arrive at the answer, here is a possible nextstep after Gary's functions: y.foldLeft(0)((m: Int, n: Int) => m+n) //returns 233168 Checkout: http://oldfashionedsoftware.com/2009/07/10/scalacodereviewfoldleftandfoldright/ for a good explanation on the foldLeft() function. Therefore this problem can be solved using Scala Collections.

Re: The Project Euler Challenge  Exercise Your Scala Skills  Gary Pamparà  9/28/11 1:23 PM  No arguments at all. Learning is the most important thing :) Euler problems are really, really entertaining  albeit that the later For numeric types, such as Int in this case, the sum function is also Eg (using the defined y value): y.sum == 233168 Regards, 
Re: The Project Euler Challenge  Exercise Your Scala Skills  Pavel Tcholakov  9/28/11 10:01 PM  Hey guys, new here! Good to have a local Scala forum at last! As well as Project Euler, this is a great resource for learning Scala: http://aperiodic.net/phil/scala/s99/ Adapted from the similar "99 Prolog problems" and "99 Lisp problems" P. 
Re: The Project Euler Challenge  Exercise Your Scala Skills  Mitch Wong Ho  9/29/11 4:33 AM  Thanks for the extra challenges, Pavel. Good tip, Gary. 
#2 By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the evenvalued terms.  Mitch Wong Ho  10/3/11 12:33 AM  Each new term in the Fibonacci sequence is generated by adding the
previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the evenvalued terms. 