Skip to content

Instantly share code, notes, and snippets.

@philtomson
Created June 12, 2011 06:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philtomson/1021309 to your computer and use it in GitHub Desktop.
Save philtomson/1021309 to your computer and use it in GitHub Desktop.
FizzBuzz OCaml
let fizzbuzz i = match ((i mod 3), (i mod 5)) with
| (0,0) -> "fizzbuzz"
| (_,0) -> "buzz"
| (0,_) -> "fizz"
| (_,_) -> string_of_int i ;;
let do_fizzbuzz n = for i = 1 to n do
Printf.printf "%s\n" (fizzbuzz i)
done ;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment