Source

Project Euler / 9 / solution.pl

#!/usr/bin/swipl -s

pythagoras(X,Y,Z,N) :-
   length(_, N),
   between(1,N,X),
   between(1,N,Y),
   between(1,N,Z),
   Z + Y + X =:= N,
   Z*Z =:= X*X + Y*Y.

% Subsequently realised I can use Euler's equation to solve
% analytically for n=20, m=5; much easier