go to previous page   go to home page   go to next page

Answer:

Yes.


Definition that uses another Function

As long as Pyramid() is completely defined somewhere, everything is fine.

Here (for reference) is Pyramid() :

Pyramid(1) = 1
Pyramid(N) = Pyramid(N-1) + Triangle(N)

And here (for review) is Triangle():

Triangle( 1 ) = 1
Triangle( N ) = N + Triangle( N-1 )

Given these two definitions, Pyramid() is completely defined. In the static view of recursion, all you need to do is rewrite the math-like definitions as Java, and you are done.


QUESTION 5:

Rewrite the definition as Java:

public int Pyramid( int N )
{
  if (  ==    ) 
  
    return    ;
     
  else
  
    return    (   ) +    (    );
}

Fill in the blanks. (You can easily do this with copy-and-paste from the definition of Pyramid.)


go to previous page   go to home page   go to next page