(* If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. *) (* sum up all numbers below n multiple of 3 or 5 *) let sumup n = let rec sumup m3 m5 s = if (m3>n) then s else if (m3=m5) then ( sumup (m3+3) (m5+5) (s+m3) ) else if (m3>m5) then ( sumup m3 (m5+5) (s+m5) ) else ( sumup (m3+3) m5 (s+m3) ) in sumup 0 0 0 ;; Printf.printf "%d\n" (sumup 1000);;