[plt-scheme] Fac calculus and memory swapping...
Hello
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)
1
(* 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