Computing.Net > Forums > Programming > Java Rookie, Recursion problem

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Java Rookie, Recursion problem

Reply to Message Icon

Name: RocketFB640
Date: November 8, 2005 at 18:40:26 Pacific
OS: Windows XP
CPU/Ram: 2.8 GHZ / 512MB
Comment:

Hey all,

I'm a rookie programmer in a low level java programming course. My problem is that I'm trying to write a small program that finds the sum of a number (Ex: 123) using a recursive method. I know this can be easily done using loops, but unfortunately I'm not allowed to do it that way. Now, I do know that I need to have a base case, but I'm not sure what that even means? I understand that if I take the number (123) and use integer divison to divide by 10 I will get the next two numbers minus the last number (123 % 10 to get 3). I'm pretty much trying to teach myself this language because my instructor is not very helpful....hope someone can help. Thanks in advance and let me know if you need any more information.



Sponsored Link
Ads by Google

Response Number 1
Name: Dr. Nick
Date: November 8, 2005 at 22:44:43 Pacific
Reply:

What do you mean, "the sum of a number"?

For 123 do you mean 1+2+3?


0

Response Number 2
Name: RocketFB640
Date: November 8, 2005 at 22:57:19 Pacific
Reply:

Dr. Nick,

Yes, that is what I meant. However, in the process of waiting for a response I figured out what my problem was and fixed it. Thanks for the quick response!


0

Response Number 3
Name: Dr. Nick
Date: November 9, 2005 at 00:43:41 Pacific
Reply:

Hey, no problem. Glad you hear you figured it out. It's nice to find somebody who actually tries to solve their homework themselves before posting :)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Python, range regex Need file that edits data...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Java Rookie, Recursion problem

JAVA String Tokenizer problem! www.computing.net/answers/programming/java-string-tokenizer-problem/4503.html

java rmi security problem www.computing.net/answers/programming/java-rmi-security-problem/5616.html

Recursion problem help www.computing.net/answers/programming/recursion-problem-help/14320.html