[plt-scheme] Fac calculus and memory swapping...

From: Guillaume R. (tuxeed at freesurf.fr)
Date: Mon Nov 6 04:53:53 EST 2006

I'm quite a newbie in the functionnal world. So I decided to learn more on
recursive algorithms using scheme.
Here is my problem. I write this piece of code

;; should calculate n!
(define (fac n)
  (if (= n 0)
  (* n (fac ( - n 1)))))

For me this should work. Indeed it doesnt: if I try (fac 5) my computer is
swapping using 92,5% of my memory (!). I tried this snippet on a freebsd
computer with a DrScheme from 8september svn and on a linux box with a
drscheme 350.
Same results on both...So is it a memory leak or am I wrong in my definition
of n! ?
Thx for your help

Posted on the users mailing list.