Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: recursion code seems to keep running with no end (halting problem?)

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    19
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default recursion code seems to keep running with no end (halting problem?)

    hj
    Last edited by Helplessdrowningpuppy; October 6th, 2014 at 11:03 AM.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: recursion code seems to keep running with no end (halting problem?)

    Thread moved.

    Do you format your code all against the left column as in the second post of code above? If so, please indent appropriately.

    If you believe you've isolated the problem to the above while( cleanup) statement, add some print statements to figure out why it is behaving infinitely. Start by investigating why the exit condition, cleanup = false, is not occurring when you want it to.

    And I don't know if what you've posted demonstrates the problem. What is the Fibonacci class supposed to do? What are the loops and if statements doing? Please comment your code so that we (and you) know what it's supposed to be going on.

    Style point:

    This statement:

    if (cleanup == true)

    is verbose. Simply

    if ( cleanup )

    will do.

Similar Threads

  1. Replies: 4
    Last Post: March 27th, 2014, 09:57 AM
  2. Problem with running, testing code in Eclipse
    By Micheal212 in forum Java IDEs
    Replies: 7
    Last Post: February 1st, 2014, 02:31 PM
  3. basic recursion problem - code needs to be modified
    By ash12 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 6th, 2012, 08:20 AM
  4. problems running recursion, any help would be grealty appreciated!
    By local127001 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 9th, 2012, 01:17 PM

Tags for this Thread