How to solve the equation in pyDatalog?

268 Views Asked by At

The pyDatalog page shows how to implement the factorial algorithm to calculate N! values. Is it possible to modify it (eg. using predicates) to solve for which N the N! will equal a given value (eg. 6) ?

from pyDatalog import pyDatalog
pyDatalog.create_terms('factorial, N')

factorial[N] = N*factorial[N-1] 
factorial[1] = 1
print(factorial[3]==N)  # prints N=6

But I would like to ask:

print(factorial[N]==6)  # and receive N=3

Unfortunately is such case pyDatalog says:

DatalogError: Error: left hand side of comparison must be bound: >/2
0

There are 0 best solutions below