Lisp Chocolates By Numbers
(defun choc-gcd (n m)
(if (zerop (mod n m))
m
(choc-gcd m (mod n m))))
(defun chocolates-by-numbers (n m)
(/ (/ (* n m) (choc-gcd n m)) m))
This uses the greatest common divisor to figure out how many chocolates get eaten before the pattern repeats.