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]
4 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]4 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
A moving truck has more __ energy than a parked truck
Karo-lina-s [1.5K]
Kinetic energy  than parked 
7 0
4 years ago
How long is the photons journey from the milky way to earth
fgiga [73]
Well i’d love to answer your question but its missing some information. firstly the earth is within the milky way galaxy so something cannot travel “from” but if you said “through” the answer would be 299,792,458 meters a second
3 0
3 years ago
Witch statement accurately describes radiation
sammy [17]

Answer

Explanation:

radiaton is used from bombs but radiation and to cure cancer it is a toxic gas that if you smell it you can die

7 0
4 years ago
Two trucks with equal mass are attracted to each other with a gravitational force of 5.3 x 10 -4 N. The trucks are separated by
HACTEHA [7]

Answer:

7327 kg or 7.3 tons

Explanation:

We have Newton formula for attraction force between 2 objects with mass and a distance between them:

F_G = G\frac{M_1M_2}{R^2}

where G =6.67408*10^{-11} m^3/kgs^2 is the gravitational constant on Earth. M = M_1 = M_2 is the masses of the 2 objects. and R = 2.6m is the distance between them.

F_G = 5.3*10^{-4}N is the attraction force.

5.3*10^{-4} = 6.67408*10^{-11}\frac{M^2}{2.6^2}

7941265 = \frac{M^2}{2.6^2}

M^2 = 53682948.76

M = \sqrt{53682948.76} \approx 7327 kg or 7.3 tons

3 0
4 years ago
A ________ is a collection of related data, equivalent to an electronic file cabinet.
dsp73

Answer:

database

Explanation:

4 0
2 years ago
Other questions:
  • A 10L container contain 5moles of a Neon gas. What is the pressure being exerted by the gas if the temperature is 303 kelvins?
    12·1 answer
  • What do most scientists think causes Bovine Spongiform Encephalopathy (Mad Cow Disease)?
    6·2 answers
  • ___________ relates the quantities of pressure, volume, temperature, and quantitiy of moles.
    6·1 answer
  • A Goodyear blimp typically contains 5400 m³ of helium (He) at an absolute pressure of 1.10 × 10 5 1.10 × 10 5 Pa. The temperatur
    10·1 answer
  • 33. Which statement best describes a bacteria cell?a. It contains more than one cellb. It is a complete organismc. It is part of
    5·2 answers
  • What is the seventh planet from the sun?
    7·2 answers
  • The transformer supplying power to an artist's light sculpture provides 9600-V AC when supplied by 120-V AC. If there are 100 tu
    11·1 answer
  • A person tries to lift each object with a force of 25 N, upward. Which
    13·2 answers
  • The speed of a star, can you measure it? Is it constant?
    7·1 answer
  • Angelica has sprained her ankle and needs to stay off it for a few weeks, which is really frustrating because she is on the trac
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!