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
ololo11 [35]
3 years ago
8

For the recursive method below, list the base case and the recursive statement, then show your work for solving a call to the re

cur() method using any parameter value 10 or greater.
public static int recur(int n)
{
if(n < 1)
{
return 3;
}
else
{
return recur(n / 5) + 2;
}
}

Computers and Technology
1 answer:
Paul [167]3 years ago
3 0

Answer:

(a): The base case: if(n<1)

(b): The recursive statement: recur(n / 5)

(c): Parameter 10 returns 7

Explanation:

Given

The above code segment

Solving (a): The base case:

The base case is that, which is used to stop the recursion. i.e. when the condition of the base case is true, the function is stopped.

In the given code, the base case is:

<em>if(n<1)</em>

Solving (b): The recursive statement:

The recursive statement is the statement within the function which calls the function.

In the given code, the recursive statement is:

<em> recur(n / 5)</em>

<em />

Solving (c): A call to recur() using 10

The base case is first tested

if (n < 1); This is false because 10 > 1

So, the recursive statement is executed

<em>recur(n/5) +2=> recur(10/5)+2 => recur(2)+2</em>

2 is passed to the function, and it returns 2

if (n < 1); This is false because 2 > 1

So, the recursive statement is executed

<em>recur(n/5) +2=> recur(2/5)+2 => recur(0)+2</em>

2 is passed to the function, and it returns 2

<em />

if (n < 1); This is true because 0 < 1

This returns 3

So, the following sum is returned

Returned values = 2 + 2 + 3

Returned values = 7

You might be interested in
(Microsoft excel) The data selected to create a table must include
spin [16.1K]
I believe the answer is a, column headings
3 0
4 years ago
Read 2 more answers
A programming and software development professional would most likely help with
DiKsa [7]
A programming and software development professional would most likely help with
Testing a software program.
3 0
3 years ago
Use the nutrition label to determine how many calories would be consumed by drinking 1 liter of Mountain Dew.
Rus_ich [418]
1 liter of mountain dew is 170 calories
4 0
3 years ago
Read 2 more answers
How good are vw beetle heaters in winter?
Vinvika [58]
It depends on the heater but in most case it works pretty well
7 0
3 years ago
To increase security on your company's internal network, the administrator has disabled as many ports as possible. Now, however,
tia_tia [17]

Answer: 443

Explanation:

Port 443 will need to be enabled for secure transactions to go through because it is the default port for HTTPS which is the transfer protocol for secure communication.

This way your credit card transactions will be encrypted to ensure protection from those who would seek to steal your data and your money.  

8 0
3 years ago
Other questions:
  • To evaluate trends in the workforce, investigate
    14·1 answer
  • Select three examples of cryptographs. Security tokens Shared-key Malware Firewalls Message authentication code Public-key
    7·2 answers
  • Write a JAVA program that repeatedly prompts your user for a number, uses a recursive function to calculate the product of that
    8·1 answer
  • Write an essay of at least 300 words explaining your position on a proposed ban of Wikipedia in your future college. You should
    12·1 answer
  • Using the given definition of the Measurable interface: public interface Measurable { double getMeasure(); } Consider the follow
    10·1 answer
  • One side effect of companies employing more and more international workers is that, globally, countries are becoming more interd
    11·1 answer
  • Which tool determines whether or not applications, devices, and computers will work with a new operating system, while maintaini
    13·1 answer
  • How do I change my name on my Brainly Profile?
    15·2 answers
  • You need to implement a class that represents the state of a room or game section. The class will contain a room_id, a descripti
    15·1 answer
  • General Electric saves $1.6 billion per year by using its private corporate network that links its 340,000 employees. Another na
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!