(* It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. 9 = 7 + 2×1^(2) 15 = 7 + 2×2^(2) 21 = 3 + 2×3^(2) 25 = 7 + 2×3^(2) 27 = 19 + 2×2^(2) 33 = 31 + 2×1^(2) It turns out that the conjecture was false. What is the smallest odd composite that cannot be written as the sum of a prime and twice a square? *) let goldbach = (* whether x is a sum of y*y and a prime from ps *) let rec is_goldbach x ps y = ( y x = p+2*y*y) ps ) || ( is_goldbach x ps (y+1) ) ) in let rec goldbach x ps = Printf.printf "%d\n" x; if( List.exists (fun y->x mod y=0) ps) then if (( x mod 2 = 0) || (is_goldbach x ps 0)) then goldbach (x+2) ps else x else goldbach (x+2) (x::ps) in goldbach 3 [2] ;; Printf.printf "%d\n" goldbach;;