Date: 2008-03-17 01:24 pm (UTC)
just to be difficult, 1 = 5 + (2i)^2

;)

Another solution would be to simply change prime? to composite? and reverse your true and false statements:

(define primes
(stream-cons
2
(stream-filter not(composite? (integers-starting-from 3)))))

(define (composite? n)
(define (iter ps)
(cond ((> (square (stream-car ps)) n) false)
((divisible? n (stream-car ps)) true)
(else (iter (stream-cdr ps)))))
(iter primes))
This account has disabled anonymous posting.
If you don't have an account you can create one now.
No Subject Icon Selected
More info about formatting
.

Most Popular Tags

Powered by Dreamwidth Studios

Style Credit

Expand Cut Tags

No cut tags