Department of Mathematics FAS Harvard University One Oxford Street Cambridge MA 02138 USA Tel: (617) 495-2171 Fax: (617) 495-5132
FAS Computer Services to Harvard University IT: (617) 495-7777.
OCaml is an object-oriented programming language. For a start look the Wikipedia article in which an example is given to find the minimal number of people (n) so that the probability p of two having the same birthday is 50 percent.
let rec birthday p n =
     let q = (365. -. float n) /. 365. *. p  in
     if q < 0.5 then
         Printf.printf "answer = %d
" (n+1)
     else
         birthday q (n+1) ;;
birthday 1.0 1
This is compiled and run as follows:
ocamlopt birthday.ml -o birthday
./birthday


Simplicity, Clarity, Generality B.W. Kernighan, R. Pike, in "The Practice of Programming".
Privacy Digital Accessibility
HTML CSS