I would like to write factorial using core.logic. I found this prolog snippet
factorial(0, 1).
factorial(N, M):- N1 is N - 1, factorial (N1, M1), M is N*M1.
and tried to translate it to core.logic in the following way
(defne factorialo [n m]
([0 1])
([n m] (fresh [n1 m1]
(== (- n 1) n1)
(== (* n m1) m)
(factorialo n1 m1))))
(run* [q]
(factorialo 3 q))
which fails with the message
clojure.core.logic.LVar cannot be cast to java.lang.Number
[Thrown class java.lang.ClassCastException]
What is the proper way of writing factorial in core.logic?