title: Scheme prime numbers
body: <p>this is possibly much of an elementary question, but I'm having trouble with a procedure I have to write in Scheme. The procedure should return all the prime numbers less or equal to N (N is from input).</p>
  
  <pre><code>(define (isPrimeHelper x k)
    (if (= x k) #t
    (if (= (remainder x k) 0) #f
        (isPrimeHelper x (+ k 1)))))
  
  (define ( isPrime x )
      (cond
        (( = x 1 ) #t)
        (( = x 2 ) #t)
        ( else (isPrimeHelper x 2 ) )))
  
  (define (printPrimesUpTo n)
      (define result '())
      (define (helper x)
          (if (= x (+ 1 n)) result
          (if (isPrime x) (cons x result) ))
          ( helper (+ x 1)))
      ( helper 1 ))
  </code></pre>
  
  <p>My check for prime works, however the function <code>printPrimesUpTo</code> seem to loop forever. Basically the idea is to check whether a number is prime and put it in a result list.</p>
  
  <p>Thanks :)</p>