Answer:
The function definition to this question can be described as follows:
long oddevenfact(int y) //defining a method oddevenfact
{
//defining conditional statement
if (y>2) //check value is greater then 2
{
return( oddevenfact(y-2) * (long) y); //return value
}
else //else
{
return((long) y); //return its value
}
}
Step-by-step explanation:
The description of the above method definition can be described as follows:
- In the above method definition a long method "oddevenfact" is declared, which accepts an integer variable "y" as its arguments, and return value as long.
- Inside the method, a conditional statement is used, in if the block, it checks a value, that is value is greater then 2, and inside the block, a recursive function is used, that calculates its factor, and returns its value in long type.
- If the condition is not true, it will go to else block and return in long type value.