I'm trying to learn F# right now coming from C# and I'm finding it a great difficulty to reconfigure my mind to the functional programming mindset. So I'm going to attempt a few Project Euler problems to learn how to code functionally.Here's my attempt at problem 1, now I'm wondering prorimarily, is this an idiomatic approach?// Project Euler - Problem 1// If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.// Find the sum of all the multiples of 3 or 5 below 1000.#lightopen Systemlet multiples = [for n in 1..1000 do if n % 3 = 0 || n % 5 = 0 then yield n]let sum = List.sum multiplesprintfn The sum of all multiples are: %d sumignore (Console.ReadKey ())
Project Euler Problem 1 - Functional approach?
programming challenge;f#
Some changes:You don't need #light any more.  I would also use |> more (this is more useful in more complex examples where it helps type inference.open System[for n in 1..1000 do if n % 3 = 0 || n % 5 = 0 then yield n]|> List.sum |> printfn The sum of all multiples are: %d Console.ReadKey () |> ignore