Yes.
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.
Of course, given a definition, creating a Java method is just a matter of translation:
Fill in the blanks. (You can easily do this with copy-and-paste from the definition of Pyramid.)