# Thread: Meaning of "multiply" in the following code?

1. Member
Join Date
Apr 2012
Posts
1
Rep Power
0

## Meaning of "multiply" in the following code?

Can someone explain the programming concept of "multiply"? i.e. What is the term for this concept in programming?

public int multiply( int n )

{

if (n == 0)

return 1;

else if (n % 2 ==1)

return n;

else

return n * multiply( n - 2);

}

2. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,712
Rep Power
14

## Re: Meaning of "multiply" in the following code?

Can someone explain the programming concept of "multiply"?? i.e. What is the term for this concept in programming?
I think you mean what is the term for a method which calls itself like that. That is "multiply" occurs twice: as the method's name and as part of the expression that is returned.

This is an AP computer science question that is doing the rounds at the moment. I suggest you consult your notes/textbook etc about the term that is used for a method that calls itself. You can find out what the method returns if multiply(8) or whatever is called by running a small program. If you are unclear about *why* that value is returned you should ask (and say what value you think should be returned, and why).

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•