# Project Euler Problem 33

It is easy to notice that these four sought fractions should be solutions for the equation

**10*z*(x – y) = y*(x – z)**

where **x,y,z** – digits 1..9, and **y < z**

From here the solution is straightforward:

let problem033 () = [for x = 1 to 9 do for y = 1 to 9 do for z = 1 to 9 do if 10*z*(x - y) = y * (x - z) && y > z then //printfn "%d/%d" (10*z + x) (10*x + y) yield (10*z + x), (10*x + y) ] |> Seq.fold (fun (numerator, denominator) (x,y) -> (numerator*x, denominator*y)) (1,1) |> fun (numerator,denominator) -> denominator/numerator

Uncommenting printfn statement above allows to reveal these four unorthodox fractions.

Advertisements

Leave a Comment