What is the sum of the first 100 consecutive integers starting with 1? It is possible to work this problem quickly without having to do repetitive sums. A very simple formula exists that will compute the sum of consecutive integers from 1 to n for any value of n. Can you discover the formula by simple reasoning and a little arithmetic
What will be an ideal response?
Input: Consecutive integers from 1 to 100
Consecutive integers from 1 to n
Output: Sum of 100 integers
Sum of n integers
Process:
Notation: Let number of integers = n
Diagram: None needed.
Approach: Work the general problem first.
Then use formula to find case when n = 100
There are several ways to approach the general solution to this problem. The approach below uses the hint and makes use of the definition for the arithmetic mean given in section A-6.
Average = sum of n numbers / count of n numbers Sum of n numbers .= average * count of n numbers Count of n numbers = n
Sum of n numbers — average * n (Equation 1)
We now have a new problem: Find the average of the first n integers
starting with one.
The average for all numbers in the sum can be found by noting that opposite pairs of numbers all have the same average:
Last (n) and first (1) number is: =(n+ 1)/2
Second from last (n — 1) and second number (2): —(n-1+2)/2 =(n+ 1)/2
Third from last (n — 2) and third number (3):
=(n-2 +3)/2 -=(n+1)/ 2
All these opposite pairs have the same average: = (n + 1) I 2
You might also like to view...
To create a connection between a file and a program, the file must be __________.
Fill in the blank(s) with the appropriate word(s).
Answer the following statements true (T) or false (F)
1. If we want to find the median of 100 scores, we need 100 separate variables to hold the data.. 2. An array behaves like a list of variables each of which is of the same type and for which there is a uniform, convenient naming convention that can be declared in a single line of code. In the explanation, give an example of declaration and access. 3. With arrays, indices start at any number the programmer chooses to indicate in the definition. 4. The programmer should always use a defined constant in an array declaration.
Application software programs are sometimes called just apps.?
Answer the following statement true (T) or false (F)
Which command below can be used to start, stop, or restart any daemons in the /etc/init.d directory?
A. daemon B. manip-daemon C. service D. daemon-service