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
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.
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 :)
Summary: hi im currently trying to construct a piece of code that uses a string tokenizer to find statements within a given piece of code( ie for...while...if.....switch etc) I have neber used the sting tokeni...
Summary: in rmi, i have done the program,its compile but doesn't run.. its show security related error... this is my policy file //pp.policy grant { permission java.net.SocketPermission "*:1300","connect...
Summary: Hi, I'm trying to solve a 2-ladder problem using recursion. The idea is given a number of ladder rungs (some may be broken), determine if it's possible to move down the ladder successful. For exam...