AP computer science questions
public int multiply( int n )
if (n == 0)
else if (n % 2 ==1)
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!
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