Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(^)/2 operator is too defensive #305

Closed
ghost opened this issue Jun 5, 2018 · 1 comment
Closed

(^)/2 operator is too defensive #305

ghost opened this issue Jun 5, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 5, 2018

SWI-Prolog can compute 9^(9^9) without a resource error and
very quickly ( :-) ), even if despite it has ca. 370 million digits:

   Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.15)
   SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.

   ?- [user].
   pow(_,0,1) :- !.
   pow(X,1,X) :- !.
   pow(X,N,Y) :-
        M is N//2, pow(X,M,A),
        J is N mod 2, pow(X,J,B),
        Y is (A*A)*B.
   ^D

   ?- pow(9,9,X).
   X = 387420489.

   ?- time((pow(9,9,X), pow(9,X,_))).
   % 159 inferences, 7.500 CPU in 8.514 seconds (88% CPU, 21 Lips)
@JanWielemaker
Copy link
Member

Thanks. Fixed with 5af3226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant