Skip to content

Instantly share code, notes, and snippets.

@musoftware
Created February 15, 2014 21:13
Show Gist options
  • Save musoftware/9025316 to your computer and use it in GitHub Desktop.
Save musoftware/9025316 to your computer and use it in GitHub Desktop.
Largest palindrome product
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