Write a function that is passed in a positive integer, n, and sum up all the digits from 1 to n, doubling the even numbers. In other words, calculate and return the following sum. if n is odd: 1 (2 * 2) 3 (4 * 2) ... ((n - 1) * 2) n if n is even: 1 (2 * 2) 3 (4 * 2) ... (n - 1) (n* 2)

Answers

Answer 1

Answer:

Written in Python

def sums(n):

    total = 0

    for i in range(1,n+1):

         if i%2 == 0:

              total = total + i*2

         else:

              total = total + i

    return(total)

Step-by-step explanation:

The function is written in Python

def sums(n):

This initializes total to 0

    total = 0

This iterates through the integers that makes up n i.e. 1,2,3.....n

    for i in range(1,n+1):

This checks if current digit is even

         if i%2 == 0:

If yes, it adds the double of the digit

              total = total + i*2

         else:

If otherwise, it adds the digit

              total = total + i

This prints the calculated sum or total

    return(total)

To call the function from main, use the following:

print(sums(n))

Where n is a positive integer. i.e. [tex]n \geq 1[/tex]


Related Questions

An astronaut is returning to Earth in a spacecraft. If the spacecraft is descending at a rate of 13.81 kilometers per minute, what will be its change in height after 512 minutes? Round your answer to the nearest kilometer.

Answers

Answer: 37.07 km

Step-by-step explanation: you would divide 512 by 13.81 to get the answer.

Answer:

Step-by-step explanation:

The automaker of your new car recommended an oil change following the 5,000 miles and then every 3,000 miles thereafter.if you plan to drive the car 250 miles a week, how many oil changes will you need the first year?

Answers

Answer:

3 oil changes

Step-by-step explanation:

1. Find an equation that represents this word problem: 3000x + 5000 = y

Where y = the # of miles total. y = 250 miles/week * 52 weeks/year = 13000 miles.

2. Solve for x: 3000x + 5000 = 13000   3000x=8000

3. x = 8/3 integer round down x = 2 oil changes, but plus the one after 5000 miles is a total of 3 oil changes that year

Jackie runs and dances for 75 minutes every day.
She dances 25 minutes more than she runs.
Part A: Write a pair of linear equations to show the relationship between the
number of minutes Jackie runs (x) and the number of minutes she dances (y)
every day.
Part B: How much time does Jackie spend running every day? Show your work.
Part C: Is it possible for Jackie to have spent 45 minutes dancing every day?
Explain your reasoning.

Answers

Answer: A. x + y = 75 B. She spends 25 minutes running and 50 minutes dancing every day. C. Yes it is.

Step-by-step explanation: B. She spends 25 minutes running and 50 minutes dancing every day, because if she dances for 25 more minutes then she runs then we can minus 25 from 75 which we get 50. Then we take the 50 a divide it by 2 because of the two categories dancing and running. So we know she spends 25 minutes running then 25 minutes dancing but we need to add the 25 minutes to dancing. So she spends 25 minutes running and 50 dancing. C. Yes it is because she already dances for 50 minutes a day so all she needs to do is workout for 10 minutes less so 65 minutes one day.

A system of linear equation consists of multiple linear equations

The system of linear equations is: [tex]\mathbf{x + y = 75}[/tex] and [tex]\mathbf{y = 25 + x}[/tex]She spends 25 minutes runningIt is possible to dance 45 minutes every day

(a) A pair of linear equations

She dances and runs for 75 minutes.

So:

[tex]\mathbf{x + y = 75}[/tex]

She dances 25 minutes more than she runs.

So:

[tex]\mathbf{y = 25 + x}[/tex]

So, the system of linear equations is: [tex]\mathbf{x + y = 75}[/tex] and [tex]\mathbf{y = 25 + x}[/tex]

(b) The time she spends running every day

Substitute 25 + x for y in [tex]\mathbf{x + y = 75}[/tex]

[tex]\mathbf{x + 25 + x = 75}[/tex]

Subtract 25 from both sides

[tex]\mathbf{2x = 50}[/tex]

Divide both sides by 2

[tex]\mathbf{x = 25}[/tex]

Hence, she spends 25 minutes running

(c) Is it possible to dance 45 minutes each day

We have:

[tex]\mathbf{y = 25 + x}[/tex]

So:

[tex]\mathbf{y = 25 + 45}[/tex]

[tex]\mathbf{y = 70}[/tex]

This means that, she has to spend less minute running and dancing.

Read more about system of equations at:

https://brainly.com/question/12895249

Can anyone help me with this?

Answers

Answer:

B

Step-by-step explanation:

it says each month and i think i saw 35 as the first month so n would go behind it so yea

I need help help......

Answers

Answer:

Y = x - 4

Step-by-step explanation:

Y = x - 4

if you substitute x for all the x on the table, it will equal to the y on the table

Ex. If x is -1

y = -1 - 4 = -5

5. Pens are sold in a local store for 80 cents each. The factory has $1200 in fixed costs plus 5 cents of additional expense for each pen made. Assuming all pens manufactured can be sold, find the break-even point.

Answers

Answer:

22

Step-by-step explanation:

,

Which of the following pairs of lines are perpendicular?

y=3x-4 and y=-1/2 x-5
y=1/2 and y=2x-1
y=x and y=-x
Please help with this. 60 points for this!

Answers

Answer:

y=x y=-x

Step-by-step explanation:

Answer:

y= 12x4

Step-by-step explanation:

i have a degree for this stuff

En el estante de un negocio hay 2 tipos de tarros de la misma mermelada y marca. El tarro más alto tiene el doble de altura que el otro, pero su diámetro es la mitad del diámetro del otro. El tarro más alto vale $4.500 y el más bajo $8.000, ¿ cuál es la mejor compra ? help

Answers

Answer:

tarro corto

Step-by-step explanation:

Aquí tenemos que comprar el frasco que tiene el menor costo por volumen.

[tex]h_1[/tex] = Altura del frasco corto

[tex]h_2[/tex] = La altura del frasco alto es el doble que el del frasco corto. = [tex]2h_1[/tex]

[tex]d_1[/tex] = Diámetro del frasco corto

[tex]d_2[/tex] = El diámetro del frasco alto es la mitad del frasco corto = [tex]\dfrac{1}{2}d_1[/tex]

El volumen de un cilindro es [tex]\pi \dfrac{d^2}{4}h[/tex]

La razón de los volúmenes de los frascos es

[tex]\dfrac{V_1}{V_2}=\dfrac{\pi\dfrac{d_1^2}{4}h_1}{\pi\dfrac{d_2^2}{4}h_2}\\\Rightarrow \dfrac{V_1}{V_2}=\dfrac{d_1^2h_1}{d_2^2h_2}\\\Rightarrow \dfrac{V_1}{V_2}=\dfrac{d_1^2h_1}{(\dfrac{1}{2}d_1)^22h_1}\\\Rightarrow \dfrac{V_1}{V_2}=\dfrac{d_1^2h_1}{\dfrac{1}{4}d_1^22h_1}\\\Rightarrow \dfrac{V_1}{V_2}=\dfrac{1}{\dfrac{1}{2}}\\\Rightarrow \dfrac{V_1}{V_2}=2\\\Rightarrow V_1=2V_2[/tex]

El costo del frasco corto por unidad de volumen es

[tex]\dfrac{8000}{V_1}=\dfrac{8000}{2V_2}=\dfrac{4000}{V_2}[/tex]

El costo del frasco alto por unidad de volumen es

[tex]\dfrac{4500}{V_2}=\dfrac{4500}{V_2}[/tex]

[tex]\dfrac{4000}{V_2}<\dfrac{4500}{V_2}[/tex]

Entonces, el costo del frasco corto por unidad de volumen es menor que el costo por unidad de volumen del frasco alto.

Por lo tanto, deberíamos tomar el frasco corto.

Someone help me with 5 and 6 please I have to finish this RNNNN PLEASE THANK UUUU

Answers

Answer:

5: letter D

Step-by-step explanation:

JASON BASEBALL TEAM SCORES 6 RUNS EVERY 2 INNINGS. WHAT IS THE RATIO OF RUNS TO INNINGS.​

Answers

Answer:

6:2

Step-by-step explanation:

simple math ... then u simplify and the answer is 3:1

Question 2 help please

Answers

Answer:

The measure of the vertex angle is 94 degrees ⇒ A

Step-by-step explanation:

In any triangle, the sum of the measures of its interior angle is 180°In the isosceles triangle, the two base angles are equal in measures

∵ In an isosceles triangle, the measure of the base angle = (2x + 5)

∵ The base angles of the isosceles triangles are equal in measures

The measures of the base angles are (2x + 5), (2x + 5)

The measure of the vertex angle = (5x - 1)

∵ The sum of the measure of the three angles = 180°

(2x + 5) + (2x + 5) + (5x - 1) = 180

→ Add the like terms in the left side

∵ (2x + 2x + 5x) + (5 + 5 + -1) = 180

∴ 9x + 9 = 180

→ Subtract 9 from both sides

∴ 9x + 9 - 9 = 180 - 9

∴ 9x = 171

→ Divide both sides by 9 to find x

x = 19

→ Substitute the value of x in the measure of the vertex angle to find it

∵ The measure of the vertex angle = 5x - 1

∴ The measure of the vertex angle = 5(19) - 1

∴ The measure of the vertex angle = 95 - 1

∴ The measure of the vertex angle = 94°

The measure of the vertex angle is 94 degrees

a) Given g(x) = 4x – 3, what function h(x) would represent a downward shift by two units? Show your solution.

b) Sketch the original function g(x) =4x -3 and the new function that you got from letter a.
Reflect g(x) = x3 + x2 - 3x - 1 across the y -axis. What is the new function and show your work?

Answers

1.3 million is certainly for the first one

a) The solution to the transformation of the function is h ( x ) = 4x - 5

b) The reflection of function g ( x ) over y axis is f ( x ) = -x³ + x² + 3x - 1

How does the transformation of a function happen?

The transformation of a function may involve any change.

Usually, these can be shifted horizontally (by transforming inputs) or vertically (by transforming output), stretched (multiplying outputs or inputs), etc.

If the original function is y = f(x), assuming the horizontal axis is the input axis and the vertical is for outputs, then:

Horizontal shift (also called phase shift):

Left shift by c units: y=f(x+c) (same output, but c units earlier)

Right shift by c units: y=f(x-c)(same output, but c units late)

Vertical shift:

Up by d units: y = f(x) + d

Down by d units: y = f(x) - d

Stretching:

Vertical stretch by a factor k: y = k × f(x)

Horizontal stretch by a factor k: y = f(x/k)

Given data ,

Let the function be represented as g ( x )

Now , the value of g ( x ) = 4x - 3

Vertical shift:

Up by d units: y = f(x) + d

Down by d units: y = f(x) - d

On transformation of the function by a vertical shift of 2 units , we get

h ( x ) = g ( x ) - 2

Substituting the values in the equation , we get

h ( x ) = 4x - 3 - 2

h ( x ) = 4x - 5

So , the transformed function is h ( x ) = 4x - 5

b)

On reflecting the function g ( x ) over y axis , f ( x ) = g ( -x )

Substituting the value of x as -x in the function , we get

g ( -x ) = ( -x )³ + ( -x )² - 3 ( -x ) - 1

So , f ( x ) = -x³ + x² + 3x - 1

Hence , the transformed function is h ( x ) = 4x - 5

To learn more about transformation of function click :

https://brainly.com/question/26896273

#SPJ2

what is 2.48 divided by 8

Answers

Answer:

.31

Step-by-step explanation:

Answer:

0.31

Step-by-step explanation:

Solve for y: 0.3y - 2 > 7

Answers

Answer:

Y > 30

Step-by-step explanation:

two times a number added to -4, subtracted from triple the sum of eight times the number and five

Answers

Answer:

2x+(-4)-8x(3)-5

Answer:

-22a-9

Step-by-step explanation:

2a+(-4)-3(8a+5)

2a+4-24a-15

2a-24a+4-15

-22a-9

Karen earns $54.60 for working 6 hours. If the amount she earns varies directly with the
number of hours she works, how many hours would she need to work to earn an
additional $260?

Answers

Given:

Karen earns $54.60 for working 6 hours.

Amount she earns varies directly with the  number of hours she works.

She need to work to earn an  additional $260.

To find:

Number of hours she need to work to earn an  additional $260.

Solution:

Let the amount of earnings be A and number of hours be t.

According to question,

[tex]A\propto t[/tex]

[tex]A=kt[/tex]     ...(i)

where, k is constant of proportionality.

Karen earns $54.60 for working 6 hours.

[tex]54.60=k(6)[/tex]

Divide both sides by 6.

[tex]\dfrac{54.60}{6}=k[/tex]

[tex]9.1=k[/tex]

Put k=9.1 in (i).

[tex]A=9.1t[/tex]

Substitute A=260 in the above equation.

[tex]260=9.1t[/tex]

Divide both sides by 9.1.

[tex]\dfrac{260}{9.1}=t[/tex]

[tex]28.5714=t[/tex]

[tex]t\approx 29[/tex]

Therefore, she need to work extra about 29 hours to earn an  additional $260.

Please can someone help me

Answers

Answer:

A, C ,E

Step-by-step explanation:

What is a commission, as it relates to the stock market? a. The act of making stock available to buy b. A request to buy a specific kind of stock c. Profit made from selling stock d. A fee paid to a broker for making a trade Please select the best answer from the choices provided A B C D

Answers

Answer:

D. A fee paid to a broker for making a trade

Step-by-step explanation:

Commission in stocks is simply a brokerage fee that is charged when one wants to buy or sell stocks.

It is also known as trading fee and could be charged when buying and selling other investments, like exchange traded funds.

Thus, correct answer is option D.

Answer:

d

Step-by-step explanation:

You are making identical balloon arrangements for your family reunion. You have 42 maroon
balloons, 126 white balloons, and 14 orange balloons. You want each arrangement to have the
same number of each color. What is the greatest number of arrangements you can make if
every balloon is used? How many of each color of balloons will be in each arrangement?

Answers

Answer: 42 in all, 14 of each.

Step-by-step explanation

The color with the least amount of balloons is orange with 14. this means to have an equal amount of balloons for each color, you would need 14 of each color.

Answer:

42

Step-by-step explanation:

One purpose of General T.Sherman's march to the sea was to
a) break the spirits of confederate citizens
b) allow troops under his control to get rest
c) find ships and sail his soldier's to the north
d) prove that he was the most skilled union general

Answers

Answer:

A

Step-by-step explanation: He slashed across the South destroying farms and land in a scorched Earth tactic, which was really damaging to the South because the land they had was all they had.

It's not B because they didn't need rest, he wasn't sailing North so it's not C, and he didn't have anything to prove himself as a skilled general, he already was a skilled general.

25 POINTS PICTURE INCLUDED PLEASE ANSWER I NEED HELP
What expression represents the value of v?

Answers

Answer:

that is an obtuse angle and mixed with an aacute, you answer should be 45 or 50 degrees please correct me if im wrong.

Step-by-step explanation:

Simplify this terms

Answers

Is 65536 I hope it helps

Maria sold 91 tickets and Sarah sold 70 tickets. What is the ratio of the number of tickets Maria sold to the total number of tickets sold?

Answers

Answer:000000 mdmdjdjc

Step-by-step explanation:ok

First, rewrite 5/9 and 11/21 so they have a common denominator. Then, use to order 5/9 and 11/21.

Answers

5/9 and 11/21

LCM of the denominators is 63

changing their denominators to all have a common denominator of 63:

5(7)/63 = 35/63

11(3)/63 = 33/63

from the above;

5/9 > 11/21.

what is 3 1/2 minus 1 1/2

Answers

Answer:

the answer is 2! :)

Step-by-step explanation:

Linda is riding on a bike course that is 60 miles long. So far, she has ridden 54 miles of the course. What percentage of the course has Linda ridden so far?

Answers

Answer:

Linda has ridden 90% of the course

Step-by-step explanation:

To find the percentage the formula is

distance ridden so far/total distance X 100

54/60 X 100

= 0.9 X 100

= 90

=90%

Therefore Linda has ridden 90% of the course.

A teachers age is 6 years greater than 2 times a students age. A principals age is 10 years greater than 3 times the students age. If x represents the students age in years, wich expression represents how many years older the principal is than the teacher ?

Answers

Answer:

6+2x < 10+3x

Step-by-step explanation:

The expression for the teacher is 6+2x

The expression for the principal is 10+3x

To solve put them as 6+2x < 10+3x

Do the ratios
10 2
and
form a proportion?
20 4

Answers

yes because they have the same cop

HELP ASAP PLEASEEEEE​

Answers

27 miles because 4.5 cm x 6 miles = 27 so it is 27 miles

There are 50 puddles on 10 orange blossoms. each blossom has the same number of petals. how many petals are on one blossom?

Answers

there are 5 petals on one blossom
Other Questions
Click to review the online content Then answer the question(s) below. using complete sentences Scroll down to view additionalquestionsOnline Content Site 1What did the "New Negro" symbolize? Mr.Johnson was very particular about the arrangement of his classroom, so the thing he hated the most was his students caused a ruckus with their horseplay. These are idioms by the wayA). Pretend to be animalsB). Played sports C). Wrestled around with each otherD). Made anima noises 4. The _________ developed a money economy where silver and gold coinage was used to make purchases. 5._________ was the founding father of the Hebrew people. *Which of the following cannot be an example of projectile motionA. A football flying through the airB. An apple falling from a treeC. A pencil rolling on the ground D.A rocket dropping from its maximum height f(x) = 3x + 1f(2)=? The normal shape of an enzyme is as shown in structure A. If the enzymes shape changes to that shown in structure B, what are two consequences of this change?less binding of substratemore binding of substratewont follow the lock-and-key pattern of enzyme bindingwill follow the lock-and-key pattern of enzyme bindinga substrate reaction independent of the enzyme structure All new bills are given a letter and number code; following their coding, they are then __________ to committees for closer inspection.A.passed alongB.referredC.directedD.dropped In what battle did the new federal army defeat Native Americans trying to defendtheir land in the west?1.Battle of Yorktown2.Battle of Fallen Timbers3.Siege of Vicksburg4.Battle of Saratoga Question 5 (1 point)Vanessa had a collection of dimes and quarters which added to $4.70. She had 23 coins in all. How many dimes and quarters does she have?# of dimes:# of quarters: Suppose that 23 inches of wire costs 92 cents. At the same rate, how much (in cents) will 36 inches of wire cost? If you help me with 3 and 4 you will be marked as brain list if its both right jim crow policing which of your predictions turned out to be true math help please help Please answer correctly !!!!!!!!!!!!!!!! Will mark brainliest !!!!!!!!!!!!!!!!!!!!! Which ancient society helped to create the concept of citizenship?GreeceEgyptPhoeniciaGermany Retype these sentences, making them smoother by changing the parts that are italicized.1. Due to the fact that I failed my last test, I need to study in order to raise my grade in history.2. I like ice cream equally as well as I like frozen yogurt bars.3. If and when the team wins the championship, we will have a celebration.4. Danny skipped the second grade with the result that he is now the youngest member of our class. An employee is walking home from work and wants to take the long way to get more exercise. The diagram represents the twodifferent routes, where A is the employee's work and B is the employee's home. Which route is longer and by how much? will mark brainliest YALLLLLL CANNNN DOOOOO THISSSSS 9x+7y=7 find the slope You rent a bike for a flat rate of $15 plus additional charge of $2.50 per hour. Write an equation to model the total cost C in terms of the number of hours H you rent the bike