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
dexar [7]
3 years ago
9

14) Modify the method that calculates the sum of the integers between 1 and N. Have the new version match the following recursiv

e definition: The sum of 1 to N is the sum of 1 to (N/2) plus the sum of (N/2 1) to N. Trace your solution using an N of 7.
Physics
1 answer:
Setler [38]3 years ago
8 0

Explanation:

Let solve the program using Java programming language

Method: method means group of statements to perform some operation.

             let call the method sum.

Parameters: list of variables that are use in the method for declaration.

<u>The code</u>

public int sum (int number)

int answer;

if (number == 1)

answer = number;

else

{

int half = number/2;

int span = number - half;

answer = sum(half) + sum(span) + (half * span);

}

answer result;

}

Firstly we defined the method called sum(), the method takes only one parameter which is number and return the answer(sum of  the integers 1 and N).

if the number is equal to 1, so it will return the number and if the number is not equal to 1 it will divide the number by 2 and get the span(span used to shift upper range).And result will add sum of half, sum of span and product of half span.

You might be interested in
An "emergency blow" is a procedure used by military submarines to quickly rise to the surface in case of trouble. It involves us
sleet_krkn [62]

Answer:

Check the explanation

Explanation:

Kindly check the attached image below to see the step by step explanation to the question above.

7 0
4 years ago
Please help me with this review question.
jolli1 [7]

Answer:

28.7%

Explanation:

efficiency = work output /work input × 100

8 0
3 years ago
Which process generates energy in the Sun?1) nuclear fusion2) nuclear fission3) chain reaction4) transmutation
Ber [7]

1) nuclear fusion

During nuclear fusion, the high pressure and temperature in the sun's core cause nuclei to separate from their electrons. During this process, radiant energy is released.

5 0
1 year ago
The human ear canal is, on average, 2.5cm long and aids in hearing by acting like a resonant cavity that is closed on one end an
Troyanec [42]

Answer:

3400 Hz

Explanation:

We know that

1 cm = 0.01 m

L = Length of the human ear canal = 2.5 cm = 0.025 m

V = Speed of sound = 340 ms⁻¹

f = First resonant frequency

The human ear canal behaves as a closed pipe and for a closed pipe, nth resonant frequency is given as

f = \frac{(2n - 1)V}{4L}

for first resonant frequency, we have n = 1

Inserting the values

f = \frac{(2(1) - 1) 340}{4(0.025)}

f = \frac{340}{4(0.025)}

f = 3400 Hz

4 0
3 years ago
Which of the following allows the human body to maintain stability in response to a viral infection
tiny-mole [99]
The spine is the one that keeps a huminss body mantaned
3 0
3 years ago
Other questions:
  • A gas sample enclosed in a rigid metal container at room temperature (20.0∘C) has an absolute pressure p1. The container is imme
    11·1 answer
  • Find change of velocity for:<br> 0-1.7 s<br> 1.7-6s
    8·1 answer
  • A boat crosses a river of width 244 m in which the current has a uniform speed of 1.99 m/s. The pilot maintains a bearing (i.e.,
    5·1 answer
  • A 4.0 kg model rocket is launched, shooting 50.0 g of burned fuel from its exhaust at an average velocity of 625 m/s. What is th
    9·1 answer
  • An α particle is a helium nucleus and has mass 4 u, which is "4 atomic units." suppose it collides head-on in an elastic collisi
    15·1 answer
  • During the rainy season, we can observe lighting in the sky. Due to lighting, the atmospheric
    8·1 answer
  • Someone Help me please
    10·1 answer
  • Can someone pretty please help? will give brainliest and thats a promise
    7·2 answers
  • What direction would the north pole of a bar magnet point if you were to hang the bar magnet from a thin string?.
    14·1 answer
  • Do two bodies have to be in physical contact to exert a force upon one another?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!