Created
November 5, 2019 11:09
-
-
Save vyzo/e113490c22d1b7b6cd71d49dc7869a69 to your computer and use it in GitHub Desktop.
pythagorean triples with for loops and explicit step
This file contains hidden or 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 1)) | |
(y (in-range x z 1))) | |
(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