Algorithm to find out the sum of first 100 even numbers
Answers
Answer:
Formula = 2(1+2+3…+50)
=2 * 50(50 + 1)/2
=50(50 + 1)
=50(51)
=2600
So the algorithm is simple .
For even numbers in between 1 and x
Y = x/2
2×y(y+1)
Explanation:
We are aware that there are 50 even numbers between 1 and 100.
Thus, n = 50
According to the formula for the sum of even numbers, Sn = n(n+1),
Sn = 50(50+1) = 50 x 51 = 2550
Algorithm:
Step 1: Begin
Step 2: Review the maximum number of n.
Step 3: Set I = 1
Step 4: Set sum to 0
Step 5: Repeat steps 6, 7, and 8 up until i=n.
Step 6: Proceed to step 7 if i%2==0.
Step 7: Determine sum = sum + I
Step 8: Determine i=i+1.
Step 9: Print the total of all even numbers.
10th step: stop
Using the formula n * (n + 1), the sum of the first 100 even numbers may be calculated in O(1) time complexity.
#SPJ3
Answer: Algorithm is given below.
Explanation:
To Find : Algorithm to find out the sum of first 100 even numbers
Concept :
Sum of first n terms of a given Arithmetic Progression is described as :
= (n/2) * [2*a + (n-1)*d]
where, a is the first term of the series and d is the common difference between the adjacent terms of the series.
In this case, a = 2, d = 2, as we have to find the sum of first 100 even numbers applying these values to eq. , we get
Sum = (n/2) × [2 × 2 + (n-1) × 2]
= (n/2) × [4 + 2 × n - 2]
= (n/2) × (2 × n + 2)
= n × (n + 1)
So, there are 100 even numbers between 1 and 200.
Algorithm:
Step 1: Start
Step 2: Determine the maximum number of n.
Step 3: Set count = 1
Step 4: Set sum to 0
Step 5: Repeat steps 6, 7, and 8 till count =n.
Step 6: Move to step 7 if count%2==0.
Step 7: Calculate sum = sum + count
Step 8: Calculate count = count +1.
Step 9: Print the total of all even numbers in the series.
Step 10 : Stop
___________________________________________________
Related links :
Write down the purpose for which programmer use algorithm ?
https://brainly.in/question/36140952
State the significance of Algorithm to solve a particular task.
https://brainly.in/question/13881143
#SPJ3
Answer: Algorithm is given below.
Explanation:
To Find : Algorithm to find out the sum of first 100 even numbers
Concept :
Sum of first n terms of a given Arithmetic Progression is described as :
= (n/2) * [2*a + (n-1)*d]
where, a is the first term of the series and d is the common difference between the adjacent terms of the series.
In this case, a = 2, d = 2, as we have to find the sum of first 100 even numbers applying these values to eq. , we get
Sum = (n/2) × [2 × 2 + (n-1) × 2]
= (n/2) × [4 + 2 × n - 2]
= (n/2) × (2 × n + 2)
= n × (n + 1)
So, there are 100 even numbers between 1 and 200.
Algorithm:
Step 1: Start
Step 2: Determine the maximum number of n.
Step 3: Set count = 1
Step 4: Set sum to 0
Step 5: Repeat steps 6, 7, and 8 till count =n.
Step 6: Move to step 7 if count%2==0.
Step 7: Calculate sum = sum + count
Step 8: Calculate count = count +1.
Step 9: Print the total of all even numbers in the series.
Step 10 : Stop
___________________________________________________
Related links :
Write down the purpose for which programmer use algorithm ?
https://brainly.in/question/36140952
State the significance of Algorithm to solve a particular task.
https://brainly.in/question/13881143
#SPJ3