[ create a new paste ] login | about

Link: http://codepad.org/YhAGquhp    [ raw code | output | fork ]

programmingpraxis - Scheme, pasted on Nov 26:
1
2
3
4
5
6
7
8
9
10
11
; a prime number puzzle

(define (two-digit-primes)
  (let ((sieve (make-vector 100 #t)))
    (do ((p 2 (+ p 1))) ((<= 100 p) (newline))
      (when (vector-ref sieve p)
        (when (< 10 p) (display p) (display " "))
        (do ((i (* p p) (+ i p))) ((<= 100 i))
          (vector-set! sieve i #f))))))

(two-digit-primes)


Output:
1
11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 


Create a new paste based on this one


Comments: