Special pythagorean triplet: Difference between revisions
Content added Content deleted
(→{{header|Common Lisp}}: Added Common Lisp version) |
(→{{header|Common Lisp}}: Added more conventional implementation.) |
||
Line 76: | Line 76: | ||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
⚫ | |||
A conventional solution: |
|||
<lang lisp> |
|||
(defun special-triple (sum) |
|||
(loop |
|||
for a from 1 |
|||
do (loop |
|||
for b from (1+ a) |
|||
for c = (- sum a b) |
|||
when (< c b) do (return) |
|||
when (= (* c c) (+ (* a a) (* b b))) |
|||
do (return-from conventional-triple-search (list a b c))))) |
|||
</lang> |
|||
⚫ | |||
<lang lisp> |
<lang lisp> |