Created
November 5, 2019 10:37
-
-
Save vyzo/d1c09fe72da11bf2e60cf7fb925b7664 to your computer and use it in GitHub Desktop.
pythagorean triples with for loops
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
(import :std/iter) | |
(export main) | |
(def (main) | |
(declare (fixnum) (not safe)) | |
(def i 1) | |
(let/cc break | |
(for* ((z (in-naturals 1)) | |
(x (in-range 1 z)) | |
(y (in-range x z))) | |
(when (= (+ (* x x) (* y y)) (* z z)) | |
(displayln "(" x ", " y ", " z ")") | |
(if (< i 1000) | |
(set! i (1+ i)) | |
(break)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment