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: AP computer science questions

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    9
    My Mood
    Cheerful
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default AP computer science questions

    public int multiply( int n )

    {

    if (n == 0)

    return 1;

    else if (n % 2 ==1)

    return n;

    else

    return n * multiply( n - 2);

    }

    a) If the method multiply(8) is called, what is the output? I got 8 as the output but I'm not sure... It's probably either 8 or 0...
    b)What do you notice about the bolded text in regards to programming? What is this programming concept called? Explain this concept. Back up your explaination by writing out each step in the code.
    -I know that the bolded terms are the same method. The concept is 'Recursion'. Recursion is when a method calls upon itself. But what does it mean when it asks "Back up your explaination by writing out each step in the code."??

    Thanks in advance for your help!


  2. #2
    Junior Member lunix's Avatar
    Join Date
    Apr 2012
    Location
    England
    Posts
    6
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: AP computer science questions

    what it means is the exact literal translation of what it means, dry run the code with an example number to prove the recursion... I.E enter multiply(8); then explain line by line whats happening i.e 8 * 6 * 4 * 2 or something
    Feels good man

Similar Threads

  1. AP computer science questions
    By svo in forum Java Theory & Questions
    Replies: 1
    Last Post: April 7th, 2012, 02:24 PM
  2. need help in AP Computer Science!
    By eechord in forum Member Introductions
    Replies: 3
    Last Post: October 7th, 2011, 09:57 AM
  3. Frog jumping code (AP comp science help!)
    By CompScienceStudent1 in forum What's Wrong With My Code?
    Replies: 14
    Last Post: September 21st, 2011, 05:42 PM
  4. Replies: 1
    Last Post: March 11th, 2011, 02:11 PM
  5. computer science help
    By hairyjewbear in forum Algorithms & Recursion
    Replies: 6
    Last Post: November 4th, 2010, 04:05 PM