1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
AleksAgata [21]
3 years ago
7

Analyze the following recursive method and indicate which of the following will be true.

Computers and Technology
1 answer:
notsponge [240]3 years ago
7 0

Answer:

a) The method runs infinitely and causes a StackOverflowError.

// Return the factorial for a specified index

public static long factorial(int n)

{

if (n == 0)

return 1;

else

return n * factorial(n - 1);

}

b) Invoking factorial(2) returns 2.

// Return the factorial (2)

public static long factorial(int 2)

{

if (n == 2)

return 2;

else

return 2 * factorial(3 - 1);

}

c) Invoking factorial(1) returns 1.

// Return the factorial(1)

public static long factorial(int 1)

{

if (n == 1)

return 1;

else

return 1 * factorial(1 - 1);

}

d) Invoking factorial(0) returns 0.

// Return the factorial(0)

public static long factorial(int 0)

{

if (n == 0)

return 0;

else

return 0 * factorial(0 - 1);

}

Explanation:

You might be interested in
A “greedy algorithm” sometimes works well for optimization problems???
mrs_skeptik [129]
An optimization problem is one in which you want to find, not just a solution, but the best  solution •<span>A <span>“greedy algorithm” sometimes works </span></span><span>well for optimization problems </span>•<span>But only a few optimization problems can </span><span> be solved by the <span>greedy method</span></span>
5 0
3 years ago
Search engines enable you to
lord [1]
Search engines enable you to locate web pages related to a specific subject.
4 0
3 years ago
Read 2 more answers
Received a $600 utility bill for electricity usage in july to be paid in august.
Marizza181 [45]
I guess the answer would be B if it was a choice.
<span>b. owed wages to 10 employees who worked three days at $100 each per day at the end of July. the company will pay employees at the end of the first week of august.</span><span />
5 0
4 years ago
What am I doing wrong?
Temka [501]

In your example, you're asking the user for a number and then you're setting total and nums equal to zero. This results in your first number being ignored by the program. I included the complete working code below:

num = int(input("Enter a number: "))

total = num

nums = 1

while (total <= 100):

   num = int(input("Enter a number: "))

   nums = nums + 1

   total = total + num

print("Sum: "+str(total))

print("Numbers Entered: "+str(nums))

I hope this helps!

8 0
3 years ago
Expectation on Information Technology Fundamental​
gizmo_the_mogwai [7]

You can expect to develop an understanding of information systems, programming languages, information management and artificial intelligence, leaving your studies with the ability to apply your knowledge to solve problems.

7 0
3 years ago
Other questions:
  • What does it mean when #DIV/0! is displayed and a green triangle is added to the upper-left corner of a cell? A. The formula can
    10·2 answers
  • An employee who interacts with customers regarding the nature of their car problems, rather than actually working on the vehicle
    12·2 answers
  • AW Computing uses a private sharing model for cases. A select group of five users need read/write access to all cases with a spe
    8·1 answer
  • Plz answer me will mark as brainliest​
    6·1 answer
  • an IPv6 packet has a 40 byte base header, a 20 byte destination options extension header (which is not used for routing) and 200
    5·1 answer
  • Crees que el uso del internet ha mejorado nuestra vida o somos esclavos de ella​
    10·2 answers
  • a. a large central network that connects other networks in a distance spanning exactly 5 miles. b. a group of personal computers
    7·1 answer
  • True or False: Mapping annotations are exclusive - an annotated method will only be accessible to requests sent to a matching UR
    14·1 answer
  • Complete main() to read dates from input, one date per line. Each date's format must be as follows: March 1, 1990. Any date not
    9·1 answer
  • What should you do if a headset plugged into your computer is not working properly.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!