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.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.