RosettaCodeData/Task/List-comprehensions/Common-Lisp/list-comprehensions-1.lisp
2023-07-01 13:44:08 -04:00

6 lines
278 B
Common Lisp

(defun pythagorean-triples (n)
(loop for x from 1 to n
append (loop for y from x to n
append (loop for z from y to n
when (= (+ (* x x) (* y y)) (* z z))
collect (list x y z)))))