Skip to content

Instantly share code, notes, and snippets.

@nagat01
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save nagat01/d7ce4d734634fbfe127a to your computer and use it in GitHub Desktop.

Select an option

Save nagat01/d7ce4d734634fbfe127a to your computer and use it in GitHub Desktop.
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