Ask Question
14 October, 09:07

private int product (int n) { if (n < = 1) return 1; else return n * product (n-2); } What is the output when product (6) is called?

+4
Answers (1)
  1. 14 October, 13:02
    0
    48

    Explanation:

    In this code, there is a method i. e "product" of "int" type it means it returns the integer value. The description of the given code is given below

    Initially when product (6) function is called the else block will be executed so return (6) * product (4). As we saw that above product (4) is a recursion function " Function which calls itself again and again ". so again else block is executed now the value is return (6) * return (4) * return (2);

    So it returns 48
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “private int product (int n) { if (n < = 1) return 1; else return n * product (n-2); } What is the output when product (6) is called? ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers