Created
December 9, 2019 09:12
-
-
Save ichiban/870dfa9211dad9f78b119516908dda0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env swipl | |
:- use_module(library(clpfd)). | |
:- initialization(main, main). | |
main(_) :- | |
current_prolog_flag(max_tagged_integer, Max), | |
between(3, Max, N), | |
fermat(X, Y, Z, N), | |
format('X = ~d~n', X), | |
format('Y = ~d~n', Y), | |
format('Z = ~d~n', Z). | |
fermat(X, Y, Z, N) :- | |
Vars = [X, Y, Z], | |
current_prolog_flag(max_tagged_integer, Max), | |
Vars ins 1..Max, | |
X ^ N + Y ^ N #= Z ^ N, | |
label(Vars). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment