Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a965f40835
Fetching contributors…

Cannot retrieve contributors at this time

file 13 lines (8 sloc) 0.368 kb
1 2 3 4 5 6 7 8 9 10 11 12 13
(*
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
*)

let rec gcd i j = if j = 0L then i else gcd j (i%j)

let lcm i j = i * j / (gcd i j)

let smallest = {1L..20L} |> Seq.fold(lcm)(1L)

printfn "%i" smallest
Something went wrong with that request. Please try again.