#!/usr/local/bin/kalypso
; Bogus but simple recursive prime number routine
; Bart 2-87

; returns t if n is prime wrt the elements of the list a
; or nil otherwise

(defun prime-wrt (a n)
  (cond
   ((nil? a) t)
   ((= 0 (mod n (car a))) nil)
   (t (prime-wrt (cdr a) n))
   )
  )

; returns a list containing the primes from 1 to n

(defun primes-from-1-to (n)
  (cond
   ((< n 3) '(2))
   (t
    (let ((a (primes-from-1-to (1- n))))
      (cond
       ((prime-wrt a n) (cons n a))
       (t a)
       )
     )
    )
   )
  )
(patom (reverse (primes-from-1-to (sread (car argv)))))
(terpr)
