Setting up hardware and software

Calculate the sum of numbers from 1 to 100. Fun mathematics: Gauss' rule

I was lazy. To keep the children occupied for a long time, and to take a nap himself, he asked them to add numbers from 1 to 100.

Gauss quickly gave the answer: 5050. So fast? The teacher did not believe it, but the young genius turned out to be right. Adding all the numbers from 1 to 100 is for weaklings! Gauss found the formula:

$$\sum_(1)^(n)=\frac(n(n+1))(2)$$

$$\sum_(1)^(100)=\frac(100(100+1))(2)=50\cdot 101=5050$$

How did he do it? Let's try to figure it out using the example of a sum from 1 to 10.

The first way: divide the numbers into pairs

Let's write the numbers from 1 to 10 as a matrix with two rows and five columns:

$$\left(\begin(array)(c)1&2&3&4&5\\ 10&9&8&7&6 \end(array)\right)$$

I wonder if the sum of each column is 11 or $n+1$. And there are 5 such pairs of numbers or $\frac(n)(2)$. We get our formula:

$$Number\of\columns\cdotSum\of\numbers\in\columns=\frac(n)(2)\cdot(n+1)$$

What if there is an odd number of terms?

What if you add the numbers from 1 to 9? We are missing one number to make five pairs, but we can take zero:

$$\left(\begin(array)(c)0&1&2&3&4\\ 9&8&7&6&5 \end(array)\right)$$

The sum of the columns is now 9 or exactly $n$. What about the number of columns? There are still five columns (thanks to zero!), but now the number of columns is defined as $\frac(n+1)(2)$ (we have $n+1$ numbers and half as many columns).

$$Number\of\columns\cdotSum\of\numbers\in\columns=\frac(n+1)(2)\cdot n$$

Second way: double it and write it in two lines

We calculate the sum of numbers slightly differently in these two cases.
Maybe there is a way to calculate the sum equally for even and odd numbers of terms?

Instead of making a kind of “loop” out of numbers, let’s write them in two lines, and multiply the number of numbers by two:

$$\left(\begin(array)(c)1&2&3&4&5&6&7&8&9&10\\10&9&8&7&6&5&4&3&2&1 \end(array)\right)$$

For the odd case:

$$\left(\begin(array)(c)1&2&3&4&5&6&7&8&9\\9&8&7&6&5&4&3&2&1\end(array)\right)$$

It can be seen that in both cases the sum of the columns is $n+1$, and the number of columns is $n$.

$$Number\of\columns\cdotSum\of\numbers\in\columns=n\cdot(n+1)$$

But we only need the sum of one row, so:

$$\frac(n\cdot(n+1))(2)$$

Third way: make a rectangle

There is another explanation, let's try to add crosses, let's assume we have crosses:

It just looks like a different representation of the second method - each subsequent row of the pyramid has more crosses and fewer zeros. The number of all crosses and zeros is the area of ​​the rectangle.

$$Area=Height\cdotWidth=n\cdot(n+1)$$

But we need the sum of the crosses, so:

$$\frac(n\cdot(n+1))(2)$$

Fourth method: arithmetic mean

It is known: $Mean\ arithmetic=\frac(Sum)(Number\ members)$
Then: $Sum = average\arithmetic\cdotNumber\of terms$

We know the number of members - $n$. How to express the arithmetic mean?

Notice that the numbers are evenly distributed. For every large number, there is a small one located at the other end.

1 2 3, average 2

1 2 3 4, average 2.5

In this case, the arithmetic mean is the arithmetic mean of the numbers 1 and $n$, that is, $Arithmetic mean=\frac(n+1)(2)$

$$Sum = \frac(n+1)(2)\cdot n$$

Fifth method: integral

We all know that a definite integral calculates a sum. Let's calculate the sum from 1 to 100 using an integral? Yes, but first let's at least find the sum from 1 to 3. Let our numbers be a function of y(x). Let's draw a picture:

The heights of the three rectangles are exactly the numbers from 1 to 3. Let’s draw a straight line through the middles of the “caps”:


It would be nice to find the equation of this line. It passes through the points (1.5;1) and (2.5;2). $y=k\cdot x+b$.

$$\begin(cases)2.5k + b = 2\\1.5k + b = 1\end(cases)\Rightarrow k=1; b=-0.5$$

Thus, the equation of the straight line with which we can approximate our rectangles $y=x-0.5$


She cuts off the yellow triangles from the rectangles, but “adds” blue triangles on top of them. Yellow is equal to blue. First, let's make sure that using the integral leads to the Gauss formula:

$$\int_(1)^(n+1) (x-\frac(1)(2)) \, dx = (\frac(x^(2))(2)-\frac(x)(2 ))(|)^(n+1)_(1)=\frac((n+1)^(2))(2)-\frac(n+1)(2)=\frac(n^( 2)+2n+1-n-1)(2)=\frac(n^(2)+n)(2)$$

Now let’s calculate the sum from 1 to 3, using X we take from 1 to 4 so that all our three rectangles fall into the integral:

$$\int_(1)^(4) (x-\frac(1)(2)) \, dx = (\frac(x^(2))(2)-\frac(x)(2)) (|)^(4)_(1)=\frac(4^(2))(2)-2-(0.5-0.5)=6$$

$$\int_(1)^(101) (x-\frac(1)(2)) \, dx = (\frac(x^(2))(2)-\frac(x)(2)) (|)^(101)_(1)=\frac(101^(2))(2)-50.5-(0.5-0.5)=5100.5-50.5=5050$$

And why is all this needed?

$$\frac(n(n+1))(2)=\frac(n^(2))(2)+\frac(n)(2)$$

On the first day one person visited your site, on the second day two... Every day the number of visits increased by 1. How many total visits will the site receive by the end of the 1000th day?

$$\frac(n(n+1))(2)=\frac(n^(2))(2)+\frac(n)(2)=\frac(1000^(2))(2) +\frac(1000)(2) = 500000+500=500500$$

The series “Entertaining Mathematics” is dedicated to children who are interested in mathematics and parents who devote time to the development of their children, “giving” them interesting and entertaining problems and puzzles.

The first article in this series is devoted to Gauss's rule.

A little history

The famous German mathematician Carl Friedrich Gauss (1777-1855) was different from his peers from early childhood. Despite the fact that he was from a poor family, he learned to read, write, and count quite early. There is even a mention in his biography that at the age of 4-5 he was able to correct the error in his father’s incorrect calculations simply by watching him.

One of his first discoveries was made at the age of 6 during a mathematics lesson. The teacher needed to captivate the children for a long time and he proposed the following problem:

Find the sum of all natural numbers from 1 to 100.

Young Gauss completed this task quite quickly, finding an interesting pattern that has become widespread and is still used to this day in mental calculation.

Let's try to solve this problem orally. But first, let's take the numbers from 1 to 10:

1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10

Look carefully at this amount and try to guess what unusual thing Gauss could see? To answer, you need to have a good understanding of the composition of the numbers.

Gauss grouped the numbers as follows:

(1+10) + (2+9) + (3+8) + (4+7) + (5+6)

Thus, little Karl received 5 pairs of numbers, each of which individually adds up to 11. Then, to calculate the sum of natural numbers from 1 to 10, you need

Let's return to the original problem. Gauss noticed that before adding, it is necessary to group numbers into pairs and thereby invented an algorithm that allows you to quickly add numbers from 1 to 100:

1 + 2 + 3 + 4 + 5 + … + 48 + 49 + 50 + 51 + 52 + 53 + … + 96 + 97 + 98 + 99 + 100

    Find the number of pairs in a series of natural numbers. In this case there are 50 of them.

    Let's sum up the first and last numbers of this series. In our example, these are 1 and 100. We get 101.

    We multiply the resulting sum of the first and last terms of the series by the number of pairs of this series. We get 101 * 50 = 5050

Therefore, the sum of the natural numbers from 1 to 100 is 5050.

Problems using Gauss's rule

And now we present to your attention problems in which Gauss’s rule is used to one degree or another. A fourth grader is quite capable of understanding and solving these problems.

You can give the child the opportunity to reason for himself so that he himself “invents” this rule. Or you can take it apart together and see how he can use it. Among the problems below there are examples in which you need to understand how to modify Gauss's rule in order to apply it to a given sequence.

In any case, in order for a child to be able to operate with this in his calculations, an understanding of the Gaussian algorithm is necessary, that is, the ability to correctly divide into pairs and count.

Important! If a formula is memorized without understanding, it will be forgotten very quickly.

Problem 1

Find the sum of numbers:

  • 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10;
  • 1 + 2 + 3 + … + 14 + 15 + 16;
  • 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9;
  • 1 + 2 + 3 + 4 + 5 + … + 48 + 49 + 50 + 51 + 52 + 53 + … + 96 + 97 + 98 + 99 + 100.

Solution.

First, you can give the child the opportunity to solve the first example himself and offer to find a way in which this can be done easily in his mind. Next, analyze this example with the child and show how Gauss did it. For clarity, it is best to write down a series and connect pairs of numbers with lines that add up to the same number. It is important that the child understands how pairs are formed - we take the smallest and largest of the remaining numbers, provided that the number of numbers in the series is even.

  • 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = (1 + 10) + (2 + 9) + (3 + 8) + (4 + 7) + (5 + 6) = (1 + 10) * 5;
  • 1 + 2 + 3 + … + 14 + 15 + 16 = (1 + 16) + (2 + 15) + (3 + 14) + (4 + 13) + (5 + 12) + (6 + 11) + (7 + 10) + (8 + 9) = (1 + 16) * 8 = 136;
  • 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = (1 + 8) + (2 + 7) + (3 + 6) + (4 + 5) + 9 = (1+ 8) * 4 + 9 = 45;
  • 1 + 2 + 3 + 4 + 5 + … + 48 + 49 + 50 + 51 + 52 + 53 + … + 96 + 97 + 98 + 99 + 100 = (1 + 100) * 50 = 5050

Task2

There are 9 weights weighing 1g, 2g, 3g, 4g, 5g, 6g, 7g, 8g, 9g. Is it possible to arrange these weights into three piles of equal weight?

Solution.

Using Gauss's rule, we find the sum of all weights:

1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 = (1 + 8) * 4 + 9 = 45 (g)

This means that if we can group the weights so that each pile contains weights with a total weight of 15g, then the problem is solved.

One of the options:

  • 9g, 6g
  • 8g, 7g
  • 5g, 4g, 3g, 2g, 1g

Other possible options find it yourself with your child.

Draw your child's attention to the fact that when solving similar problems, it is better to always start grouping with a larger weight (number).

Problem 3

Is it possible to divide a watch dial into two parts by a straight line so that the sums of the numbers in each part are equal?

Solution.

To begin with, apply Gauss’s rule to the series of numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12: find the sum and see if it is divisible by 2:

So it can be divided. Now let's see how.

Therefore, it is necessary to draw a line on the dial so that 3 pairs fall into one half, and three into the other.

Answer: the line will pass between the numbers 3 and 4, and then between the numbers 9 and 10.

Task4

Is it possible to draw two straight lines on a clock dial so that the sum of the numbers in each part is the same?

Solution.

To begin with, apply Gauss’s rule to the series of numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12: find the sum and see if it is divisible by 3:

1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 = (1 + 12) * 6 = 78

78 is divisible by 3 without a remainder, which means it can be divided. Now let's see how.

According to Gauss's rule, we get 6 pairs of numbers, each of which adds up to 13:

1 and 12, 2 and 11, 3 and 10, 4 and 9, 5 and 8, 6 and 7.

Therefore, it is necessary to draw lines on the dial so that each part contains 2 pairs.

Answer: the first line will pass between the numbers 2 and 3, and then between the numbers 10 and 11; the second line is between the numbers 4 and 5, and then between 8 and 9.

Problem 5

A flock of birds is flying. There is one bird (the leader) in front, two behind it, then three, four, etc. How many birds are in the flock if there are 20 of them in the last row?

Solution.

We find that we need to add numbers from 1 to 20. And to calculate such a sum we can apply Gauss’s rule:

1 + 2 + 3 + 4 + 5 + … + 15 + 16 + 17 + 18 + 19 + 20 = (20 + 1) * 10 = 210.

Problem 6

How to place 45 rabbits in 9 cages so that all cages have a different number of rabbits?

Solution.

If the child has decided and understood the examples from task 1 with understanding, then he immediately remembers that 45 is the sum of the numbers from 1 to 9. Therefore, we plant the rabbits like this:

  • first cell - 1,
  • second - 2,
  • third - 3,
  • eighth - 8,
  • ninth - 9.

But if the child cannot figure it out right away, then try to give him the idea that such problems can be solved by brute force and that one should start with the minimum number.

Problem 7

Calculate the sum using the Gaussian technique:

  • 31 + 32 + 33 + … + 40;
  • 5 + 10 + 15 + 20 + … + 100;
  • 91 + 81 + … + 21 + 11 + 1;
  • 1 + 2 + 3 + 4 + … + 18 + 19 + 20;
  • 1 + 2 + 3 + 4 + 5 + 6;
  • 4 + 6 + 8 + 10 + 12 + 14;
  • 4 + 6 + 8 + 10 + 12;
  • 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11.

Solution.

  • 31 + 32 + 33 + … + 40 = (31 + 40) * 5 = 355;
  • 5 + 10 + 15 + 20 + … + 100 = (5 + 100) * 10 = 1050;
  • 91 + 81 + … + 21 + 11 + 1 = (91 + 1) * 5 = 460;
  • 1 + 2 + 3 + 4 + … + 18 + 19 + 20 = (1 + 20) * 10 =210;
  • 1 + 2 + 3 + 4 + 5 + 6 = (1 + 6) * 3 = 21;
  • 4 + 6 + 8 + 10 + 12 + 14 = (4 + 14) * 3 = 54;
  • 4 + 6 + 8 + 10 + 12 = (4 + 10) * 2 + 12 = 40;
  • 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 = (1 + 10) * 5 + 11 = 66.

Problem 8

There is a set of 12 weights weighing 1g, 2g, 3g, 4g, 5g, 6g, 7g, 8g, 9g, 10g, 11g, 12g. 4 weights were removed from the set, the total mass of which is equal to a third of the total mass of the entire set of weights. Is it possible to place the remaining weights on two scales, 4 pieces on each scale, so that they are in balance?

Solution.

We apply Gauss's rule to find the total mass of the weights:

1 + 2 + 3 + … + 10 + 11 + 12 = (1 + 12) * 6 = 78 (g)

We calculate the mass of the weights that were removed:

Therefore, the remaining weights (with a total mass of 78-26 = 52 g) must be placed at 26 g on each scale so that they are in equilibrium.

We don't know which weights were removed, so we must consider all possible options.

Using Gauss's rule, you can divide the weights into 6 pairs of equal weight (13g each):

1g and 12g, 2g and 11g, 3g and 10, 4g and 9g, 5g and 8g, 6g and 7g.

Then the best option, when removing 4 weights will remove two pairs from the above. In this case, we will have 4 pairs left: 2 pairs on one scale and 2 pairs on the other.

The worst case scenario is when 4 removed weights break 4 pairs. We will be left with 2 unbroken pairs with a total weight of 26g, which means we place them on one pan of the scale, and the remaining weights can be placed on the other pan of the scale and they will also be 26g.

Good luck in the development of your children.

Today we will look at one of the mathematical problems that my nephew and I had to solve. And then we implement it through PHP. And let's look at several options for solving this problem.

The task:

You need to quickly add all the numbers from 1 to 100 one after another and find out the sum of all the numbers.

The solution of the problem:

In fact, the first time we solved this problem, we solved it incorrectly! But we will not write about the incorrect solution to this problem.

And the solution is so simple and trivial - you need to add 1 and 100 and multiply by 50. (Karl Gaus had this solution when he was very little...)

(1 + 100)*50.

How can I solve this problem using PHP?

Calculate the sum of all numbers from 1 to 100 using PHP.

When we had already solved this problem, we decided to see what they were writing on the Internet. this issue! And I found some form where young talents could not solve this problem and tried to do it through a cycle.

If there is no special condition to do it through a loop, then there is no point in doing it through a loop!

And yes! Don't forget that in PHP you can solve a problem in many ways!

1. This code

can add any sequence of numbers from one to infinity.

Let's implement our solution in its simplest form:

$end = $_POST["changenaya"];

CLICK HERE

Result:

2.

Calculate the sum of all numbers from any number to any number using PHP.

And let’s check the transmitted data for the number...

$two = strip_tags($_POST["peremennaya_2"]);

$tree = strip_tags($_POST["peremennaya_3"]);

if((is_numeric($two)) and (is_numeric($tree)))

$res = $tree/2*($two + $tree); echo "

Result: ". $res;

echo "No need to put any crap into the form...";< $end;), которое будет оправлено через форму.

The first parameter is zero ($i=1), the second parameter is less than or equal to this number ($i

Let's show the sequence how it will increase with each new turn of the cycle.

$end = strip_tags($_POST["peremennaya"]);< $end; $i++) {

for ($i=1; $i

$res = $res +$i;
";

echo $res." Did you like the article?
print
Was this article helpful?
Yes
No
Thanks for your feedback!
Something went wrong and your vote was not counted.
Thank you. Your message has been sent
Found an error in the text? Select it, click Ctrl + Enter