Last active
December 20, 2015 14:19
-
-
Save fukayatsu/6146160 to your computer and use it in GitHub Desktop.
http://www.slideshare.net/kazh98/ss-24868347
√2の近似値を求める
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
(define (cube n) (* n n n)) | |
(define t 0.1) | |
(define (x k) | |
(define (pre l) (x (- l 1))) | |
(if (= k 0) | |
2 | |
(- (pre k) | |
(* t (- | |
(* 4 (cube (pre k))) | |
(* 8 (pre k))))))) | |
;gosh> (x 10) | |
;1.416106250747764 | |
;この書き方だと手元の環境で(x 15)とかに数秒掛かる |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment