title: Language Scheme: find the sum of proper divisors
body: <p>I am wondering how to write a function calculating the sum of proper divisors of a integer greater than 1.</p>
  
  <pre><code>(define (sum-of-proper-divisors n)
            (cond
             [(= n 1) 1]
             [(= 0 (remainder n (sub1 n)))
              (+ (remainder n (sub1 n)) (sum-of-proper-divisors (sub1 (sub1 n))))]
             [else (sum-of-proper-divisors (sub1 n))]))
  </code></pre>
  
  <p>This is the code that I wrote, however, it does not work. It will never stop evaluating because it will always do n-1. And I don't know how to fix this. Also, there might be other problems. How to put the restriction that makes the function stop evaluating when the divisor becomes 1?</p>