Last active
August 29, 2015 14:14
-
-
Save nagat01/d7ce4d734634fbfe127a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open System | |
| let problem5 x = | |
| let primes = ResizeArray() | |
| for i in 2 .. x do | |
| if primes |> Seq.forall(fun p -> i % p <> 0) then | |
| primes.Add i | |
| primes | |
| |> Seq.map(fun p -> int(Math.Pow(float p, floor(Math.Log(float x, float p))))) | |
| |> Seq.reduce (*) | |
| |> printfn "%d" | |
| problem5 10 // 2520 | |
| problem5 20 // 232792560 | |
| // 16 * 9 * 5 * 7 * 11 * 13 * 17 * 19 = 232792560 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment