Skip to content

Commit

Permalink
pe004.ml
Browse files Browse the repository at this point in the history
  • Loading branch information
mitcc committed Jul 20, 2019
1 parent ec177b1 commit bfea8de
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions project-euler/ocaml/pe004.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
open Math_lib

let rec ff res a b i =
if a > b then res
else if Math_lib.is_palindrom (i * a) && (i * a) > res then ff (i * a) (a + 1) b i
else ff res (a + 1) b i
if a > b || (i * b) < res then res
else if Math_lib.is_palindrom (i * b) then ff (i * b) a (b - 1) i
else ff res a (b - 1) i

let rec f res x y =
if x > y then res
else if (ff res 100 999 x) > res then f (ff res 100 999 x) (x + 1) y
else f res (x + 1) y
else if (ff res 100 999 y) > res then f (ff res 100 999 y) x (y - 1)
else f res x (y - 1)

let () =
Format.printf "%d\n" (f 0 100 999)
Expand Down

0 comments on commit bfea8de

Please sign in to comment.