let classify n =
  let by3 = n mod 3 = 0 in
  let by5 = n mod 5 = 0 in
  if by3 && by5 then `FizzBuzz
  else if by3 then `Fizz
  else if by5 then `Buzz
  else `Num n

let score x = match x with
  | `FizzBuzz -> 100
  | `Fizz -> 10
  | `Buzz -> 5
  | `Num n -> n

;;

let total = ref 0 in
for i = 1 to 30 do
  total := !total + score (classify i)
done;
!total
