From an old final for my class:
Here is some prolog code:
mystery(1, 1).
mystery(N, F) :-
N1 is N-1,
mystery(N1,F1),
F is F1*N.
Question 1: What value is unified with P in
mystery(3, P).
Question 2: If a semicolon is pressed after Prolog produces and answer for mystery, and interpreter will eventually report "ERROR: Out of local stack". Why dies this occur, and how could you modify mystery to avoid the error?
Question 1: I get
P = 6 ?
Question 2: If I press semi-colon to get all answers, I get an out of local stack error. I'm not sure what this code is trying to accomplish or how to fix it so I don't go out of local stack. Any ideas?