F# and project euler.

January 14th, 2009
by Serinox

Messing around with F# trying to learn the basics. recreated the solution to problem 1 in a few moments thought I’d post it for kicks.

#light
open System
let l = [1 .. 999]
let  f = List.filter(fun i -> i % 3 = 0 || i % 5 = 0) l
let i = List.fold_left(+) 0 f
Console.WriteLine(i)
System.Console.ReadKey(true)

its nice to not have to check the final list for duplicates and that it was really easy to figure out how the filter command worked.

Posted in General, Project Euler | Comments (0)

No comments yet

Leave a Reply

You must be logged in to post a comment.