Created
February 15, 2014 21:13
-
-
Save musoftware/9025316 to your computer and use it in GitHub Desktop.
Largest palindrome product
This file contains 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 sw = System.Diagnostics.Stopwatch() | |
sw.Start() | |
let ispalindrom (x):bool = | |
let s = x.ToString().ToCharArray() |> Array.rev | |
(new string(s) = x.ToString()) | |
printfn "%d" (seq { | |
for x in 899..999 do | |
for y in x..999 do | |
if ispalindrom (x*y) then yield (x*y) | |
} |> Seq.max); | |
sw.Stop() | |
System.Console.WriteLine("Time elapsed: {0}", sw.Elapsed); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment