I am trying to export the evaluation of the factorial of 500000 to a file, for which I compile the following program:
fact(N, NF) :-
fact(1, N, 1, NF).
fact(X, X, F, F) :-
!.
fact(X, N, FX, F) :-
X1 is X + 1,
FX1 is FX * X1,
fact(X1, N, FX1, F).
Next I write:
?- fact(1, 500000, 1, F).
Next:
?- open('Factorial.txt', write, Stream), write(Stream, $F), close(Stream).
ERROR: $F was not bound by a previous query
Accomplishing tests, I verified that only this procedure works even:
?- fact(1, 5772, 1, F).
Why when I try to export the factorial of a bigger number than 5772 I obtain this:
ERROR: $F was not bound by a previous query
How do I solve this problem? I will be grateful for any help you can provide.