Menu

#17 Recursive factorial (10!) leads to StackOverflowError

open
nobody
None
5
2014-08-24
2007-10-16
Wei-ju Wu
No

Hi,

trying out the factorial function below seems to result in a StackOverflowError both in the applet version as well as the JScheme 7.2 downloaded jar file.
On Chicken, this works as expected.

(define (fac n)
(if zero? n)
1
(* n (fac (- n 1))))
(write (fac 10))
(newline)

Best,

Wei-ju

Discussion


Log in to post a comment.