By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,136 Members | 1,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,136 IT Pros & Developers. It's quick & easy.

trial recursion

P: 23
as i know that the memory of each recursive call is stored in a stack, so making many recursive calls may cause a stack overflow problem ,my question is what happens if we call factorial(5) and factorial (1000)?
Jan 3 '07 #1
Share this Question
Share on Google+
2 Replies


Ganon11
Expert 2.5K+
P: 3,652
It depends on how your function is defined. I imagine factorial(5) wouldn't have too big a problem, but factorial(1000) may be too big, depending on the computer you're using and the function definition.
Jan 3 '07 #2

P: 38
factorial(1000) may overflow your stack if it is defined recursively; furthermore, 1000 factorial is too big for even a 64-bit integer. However, factorial can be defined with a for loop, rather than recursion.
Jan 4 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.