I was making this program to find the reverse factorial of give number in prolog, but its not working it is returning false everytime. Here is the code.
fr(X,Y):-fr(X,2,Y).
fr(X,P,Y):- X =< 1,Y is P-1.
fr(X,Q,Y):-D is X/Q,
H is X mod Q,
H =:= 0,
Q1 is Q+1,
fr(D,Q1,Y).
Here is who this code is supposed to work , it takes 2 argument like this (24,Who). from two argument function I call a 3 argument function ,Which is basically check if the given number is divided by 2 and if it is then it increment in Q and check if the number is divided by 3 and so on.