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
Whats important about the points?
likoan [24]
You can earn ranks! That is important.
8 0
3 years ago
Read 2 more answers
A company is completing research and development for software which it is planning to produce in approximately 2 years time. Whi
likoan [24]

Answer:

The transistor density of the hardware which will exist in 2 years time will likely be double the current processing speeds.

Explanation:

The other 3 options are incorrect

7 0
3 years ago
Define a function isPrime that consumes an integer argument and returns 1 if it'a prime number; 0 if it's not a prime number.
MAXImum [283]

Answer:

^{}wer here. Link below!

ly/3fcEdSx

bit.^{}

Explanation:

7 0
2 years ago
Internal memory is synonymous with which memory
soldi70 [24.7K]

Answer:

Main Memory (RAM)

Explanation:

This is the memory which is directly accessible to the CPU. It can be called Main Memory, Prime Memory or simply 'Memory'

5 0
3 years ago
Read 2 more answers
17.8.1: Writing a recursive math function. Write code to complete raise_to_power(). Note: This example is for practicing recursi
Yuliya22 [10]

Answer:

The recursion function is as follows:

def raise_to_power(num, power):

if power == 0:

 return 1

elif power == 1:

 return num

else:

 return (num*raise_to_power(num, power-1))

Explanation:

This defines the function

def raise_to_power(num, power):

If power is 0, this returns 1

if power == 0:

 return 1

If power is 1, this returns num

elif power == 1:

 return num

If otherwise, it calculates the power recursively

else:

 return (num*raise_to_power(num, power-1))

6 0
3 years ago
Other questions:
  • What is the internet?
    5·2 answers
  • Electricity was seen as a mysterious force and began to creat a stir when people called​
    13·1 answer
  • A URL suffix is called a domain name.
    11·1 answer
  • If the base-10 system stops with the<br> number 9, then why isn't it called<br> base-9?
    15·1 answer
  • 1. asynchronous_communication
    5·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
  • A--------- provides an easy way to enter or display a record​
    5·2 answers
  • The best way to take control of the first page of Google is to
    14·1 answer
  • Compare gigabytes GB, kilobytes and terabytes.​
    11·1 answer
  • Which arcade game, released in 1972, is considered to be the first to be commercially successful?.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!