RosettaCodeData/Task/Square-but-not-cube/OCaml/square-but-not-cube.ocaml
2023-07-01 13:44:08 -04:00

10 lines
275 B
Text

let rec fN n g phi =
if phi < 31 then
match compare (n*n) (g*g*g) with
| -1 -> Printf.printf "%d\n" (n*n); fN (n+1) g (phi+1)
| 0 -> Printf.printf "%d cube and square\n" (n*n); fN (n+1) (g+1) phi
| 1 -> fN n (g+1) phi
| _ -> assert false
;;
fN 1 1 1