练习3-71
原文
代码
(define (Ramanujan s)
(define (stream-cadr s) (stream-car (stream-cdr s)))
(define (stream-cddr s) (stream-cdr (stream-cdr s)))
(let ((scar (stream-car s))
(scadr (stream-cadr s)))
(if (= (sum-triple scar) (sum-triple scadr))
(cons-stream (list (sum-triple scar) scar scadr)
(Ramanujan (stream-cddr s)))
(Ramanujan (stream-cdr s)))))
(define (triple x) (* x x x))
(define (sum-triple x) (+ (triple (car x)) (triple (cadr x))))
(define Ramanujan-numbers
(Ramanujan (weighted-pairs integers integers sum-triple)))
所以接下来的5个数是:
(4104 (2 16) (9 15))
(13832 (2 24) (18 20))
(20683 (10 27) (19 24))
(32832 (4 32) (18 30))
(39312 (2 34) (15 33))
感谢您的访问,希望对您有所帮助。 欢迎大家关注或收藏、评论或点赞。
为使本文得到斧正和提问,转载请注明出处:
http://blog.csdn.net/nomasp