Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.68 KB | None | 0 0
  1. (define (numbers n)
  2.   (define (createList start end xs)
  3.     (cond ((= start end) (cons end xs))
  4.           (else (cons start (createList (+ start 1) end xs)))))
  5.   (define (isPrime num start)
  6.     (cond ((= num start) #t)
  7.           ((= (modulo num start) 0) #f)
  8.           (else (isPrime num (+ start 1)))))
  9.   (define (countDeviders num start)
  10.     (cond ((= start num) (if (isPrime num 2) 1 0))
  11.           (else (if (and (= (modulo num start) 0) (isPrime start 2))
  12.                     (+ 1 (countDeviders num (+ 1 start)))
  13.                     (countDeviders num (+ 1 start))))))
  14.   (define (helper k)
  15.     (filter (lambda (x) (< (countDeviders x 2) k)) (createList 2 n '())))
  16.   helper)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement