Last active
December 23, 2015 23:29
-
-
Save NalaGinrut/6710088 to your computer and use it in GitHub Desktop.
求from到to之间所有勾股数
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
(use-modules (srfi srfi-1) (ice-9 control)) | |
(define (either . args) (shift k (for-each k args))) | |
(define (sq x) (* x x)) | |
(define (choice from to) | |
(reset (let ((ll (iota to from))) | |
(let ((x (apply either ll))(y (apply either ll))(z (apply either ll))) | |
(if (= (sq z) (+ (sq x) (sq y))) | |
(format #t "~a^2 + ~a^2 = ~a^2~%" x y z)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(choice 1 5)
==>
3^2 + 4^2 = 5^2
4^2 + 3^2 = 5^2
try 1~100 ?