# 4.1.3 Summation of Series

## ৪.১.৩ নিম্নোক্ত ধারা গুলোর যোগফল নির্ণয় কর।

1. \[8] 1 + 2 + 3 + 4 + ......... + N
   1. \[8.1] 1 + 2 + 3 + ......... + 100 _(Similar)_
2. \[9] 1 + 3 + 5 + 7 + ......... + N
   1. \[9.1] 1 + 3 + 5 + ......... + 30 _(Similar)_
   2. \[9.2] ১ থেকে ৫০০ পর্যন্ত সব বিজোড় সংখ্যার যোগফল প্রিন্ট কর। _(Similar)_
   3. \[9.3] 1 + 3 + 5 + ......... + 10 _(Similar) \[Used continue to skip even number]_
   4. \[9.4] 221+223+225+......+N _(Similar)_
3. \[10] 2 + 4 + 6 + 8 + ......... + N
   1. \[10.1] 2 + 4 + 6 + 8 + ......... + 100 _(Similar)_
4. \[11] 1 + 4 + 7 + 10 + ......... + N
5. \[12] 1 + 4 + 7 + 10 + ......... + N (উক্ত ধারার জোড় সংখ্যাগুলোর যোগফল নির্ণয় কর।)
6. \[13] 1 + 4 + 7 + 10 + ......... + N (উক্ত ধারার বিজোড় সংখ্যাগুলোর যোগফল নির্ণয় কর।)
   1. 1 + 4 + 7 + 10 + ......... + 40 _(Similar)_
      1. \[13.1] উক্ত ধারার জোড় সংখ্যাগুলোর যোগফল নির্ণয় কর।
      2. \[13.2] উক্ত ধারার বিজোড় সংখ্যাগুলোর যোগফল নির্ণয় কর।
   2. \[13.3] 1+5+9+.........+29 _(Similar)_
   3. \[13.4] 3+7+11+.........+100 _(Similar)_
   4. \[13.5] 3+6+9+……+n _(Similar)_
   5. \[13.6] 5 + 10 + 15 + 20 + ......... + N _(Similar)_
      1. \[13.7] 5 + 10 + 15 + ......... + 100 _(Similar)_
      2. \[13.8] 20+25+30+......+50 _(Similar)_
   6. \[13.9] 10 + 20 + 30 + ......... +n _(Similar)_
      1. \[13.10] 10 + 20 + 30 + ......... + 100 _(Similar)_
   7. \[13.11] 7+14+21+......+70 _(Similar)_
   8. \[13.12] 10+16+22+......+70 _(Similar)_
7. \[14] N + (N-1) + (N-2) + ......... + 4 + 3 + 2 + 1
   1. \[14.1] N + (N-2) + (N-4) + ......... + 8 + 6 + 4 + 2 _(Similar)_
   2. \[14.2] N + (N-2) + (N-4) + ......... + 7 + 5 + 3 + 1 _(Similar)_
   3. \[14.3] N + (N-7) + (N-14) + (N-21) + ......... + 28 + 21 + 14 + 7 _(Similar)_
8. \[15] 1^2 + 2^2 + 3^2 + 4^2 + ......... + N^2
   1. \[15.1] 1^2 + 3^2 + 5^2 + 7^2 + ......... + N^2 _(Similar)_
   2. \[15.2] 2^2+4^2+6^2+......+80^2 _(Similar)_
   3. \[15.3] 2^2+5^2+8^2+11^2+......+n^2 _(Similar)_
   4. \[15.4] 3^2 + 7^2 + 11^2 + ......... + n^2 _(Similar)_
   5. \[15.5] 9^2+12^2+15^2+......+90^2 _(Similar)_
   6. \[15.6] 3^2+6^2+9^2+……+n^2 _(Similar)_
9. \[16] 2^3 + 4^3 + 6^3 + 8^3 + ......... + N^3
10. \[17] N^2 + (N-10)^2 + (n-20)^2 + .........+ 40^2 + 30^2 + 20^2  + 10^2
    1. \[17.1] 90^2+80^2+70^2+......+20^2 _(Similar)_
11. \[18] 1×2 + 2×3 + 3×4 × ......... + N×(N+1)

## সমাধান

### \[8] 1 + 2 + 3 + 4 + ......... + N

{% tabs %}
{% tab title="for 1" %}
{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum;
    
    scanf("%d", &n);
    sum = 0;
    for(i = 1; i <= n; i++){
        sum = sum + i;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}
{% endtab %}

{% tab title="for 2" %}
{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum;
    
    scanf("%d", &n);
    for(sum = 0, i = 1; i <= n; i++){
        sum = sum + i;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}
{% endtab %}

{% tab title="for 3" %}
{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum = 0;
    
    scanf("%d", &n);
    for(i = 1; i <= n; i++){
        sum = sum + i;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}
{% endtab %}

{% tab title="for 4" %}
{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum = 0;
    
    scanf("%d", &n);
    for(i = 1; i <= n; i++){
        sum += i;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="while 1" %}
{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i = 1, sum = 0;
    
    scanf("%d", &n);
    while(i <= n){
        sum += i;
        i++;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}
{% endtab %}

{% tab title="while 2" %}
{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i = 1, sum = 0;
    
    scanf("%d", &n);
    while(i <= n){
        sum += i++;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}
{% endtab %}

{% tab title="do while" %}
{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i = 1, sum = 0;
    
    scanf("%d", &n);
    do{
        sum += i++;
    }while(i <= n);
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}
{% endtab %}

{% tab title="formula" %}
{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, sum = 0;
    
    scanf("%d", &n);
    
    sum = n * (n + 1) / 2;
    
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}
{% endtab %}
{% endtabs %}

| Sample Input | Sample Output |
| ------------ | ------------- |
| 10           | 55            |
| 100          | 5050          |

### \[9] 1 + 3 + 5 + 7 + ......... + N

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum = 0;
    
    scanf("%d", &n);
    for(i = 1; i <= n; i += 2){
        sum += i;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}

| Sample Input | Sample Output |
| ------------ | ------------- |
| 10           | 25            |
| 100          | 2500          |

### \[10] 2 + 4 + 6 + 8 + ......... + N

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum = 0;
    
    scanf("%d", &n);
    for(i = 2; i <= n; i += 2){
        sum += i;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}

<table><thead><tr><th width="180">Input</th><th>Sample Output</th></tr></thead><tbody><tr><td>10</td><td>30</td></tr><tr><td>100</td><td>2550</td></tr></tbody></table>

### \[11] 1 + 4 + 7 + 10 + ......... + N

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum = 0;
    
    scanf("%d", &n);
    for(i = 1; i <= n; i += 3){
        sum += i;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}

<table><thead><tr><th width="180">Sample Input</th><th>Sample Output</th></tr></thead><tbody><tr><td>10</td><td>22</td></tr><tr><td>100</td><td>1717</td></tr></tbody></table>

### \[12] 1 + 4 + 7 + 10 + ......... + N (উক্ত ধারার জোড় সংখ্যাগুলোর যোগফল নির্ণয় কর।)

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum = 0;
    
    scanf("%d", &n);
    for(i = 1; i <= n; i += 3){
        if( i % 2 == 0 ){
            sum += i;
        }
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}

<table><thead><tr><th width="180">Sample Input</th><th>Sample Output</th></tr></thead><tbody><tr><td>10</td><td>14</td></tr><tr><td>100</td><td>884</td></tr></tbody></table>

### \[13] 1 + 4 + 7 + 10 + ......... + N (উক্ত ধারার বিজোড় সংখ্যাগুলোর যোগফল নির্ণয় কর।)

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum = 0;
    
    scanf("%d", &n);
    for(i = 1; i <= n; i += 3){
        if( i % 2 == 1 ){
            sum += i;
        }
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}

<table><thead><tr><th width="180">Sample Input</th><th>Sample Output</th></tr></thead><tbody><tr><td>10</td><td>8</td></tr><tr><td>100</td><td>833</td></tr></tbody></table>

### \[14] N + (N-1) + (N-2) + ......... + 4 + 3 + 2 + 1

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum = 0;
    
    scanf("%d", &n);
    for(i = n; i >= 1; i--){
        sum += i;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}

<table><thead><tr><th width="180">Sample Input</th><th>Sample Output</th></tr></thead><tbody><tr><td>10</td><td>55</td></tr><tr><td>100</td><td>5050</td></tr></tbody></table>

### \[15] 1^2 + 2^2 + 3^2 + 4^2 + ......... + N^2

{% tabs %}
{% tab title="loop" %}
{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum = 0;
    
    scanf("%d", &n);
    for(i = 1; i <= n; i++){
        sum += i * i;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}
{% endtab %}

{% tab title="formula" %}
{% code lineNumbers="true" %}
```c
#include <stdio.h>

int main() {
    int n, sum;
    
    scanf("%d", &n);
    sum = n * (n + 1) * (2 * n + 1) / 6;
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}
{% endtab %}
{% endtabs %}

<table><thead><tr><th width="180">Sample Input</th><th>Sample Output</th></tr></thead><tbody><tr><td>10</td><td>385</td></tr><tr><td>100</td><td>338350</td></tr></tbody></table>

### \[16] 2^3 + 4^3 + 6^3 + 8^3 + ......... + N^3

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum = 0;
    
    scanf("%d", &n);
    for(i = 2; i <= n; i += 2){
        sum += i * i * i;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}

<table><thead><tr><th width="180">Sample Input</th><th>Sample Output</th></tr></thead><tbody><tr><td>10</td><td>1800</td></tr><tr><td>20</td><td>24200</td></tr></tbody></table>

### \[17] N^2 + (N-10)^2 + (n-20)^2 + .........+ 40^2 + 30^2 + 20^2  + 10^2

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum = 0;
    
    scanf("%d", &n);
    for(i = n; i >= 10; i -= 10){
        sum += i * i;
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}

<table><thead><tr><th width="180">Sample Input</th><th>Sample Output</th></tr></thead><tbody><tr><td>50</td><td>5500</td></tr><tr><td>90</td><td>28500</td></tr></tbody></table>

### \[18] 1×2 + 2×3 + 3×4 × ......... + N×(N+1)

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    int n, i, sum = 0;
    
    scanf("%d", &n);
    for(i = 1; i <= n; i++){
        sum += i * (i + 1);
    }
    printf("%d\n", sum);

    return 0;
}
```
{% endcode %}

<table><thead><tr><th width="180">Sample Input</th><th>Sample Output</th></tr></thead><tbody><tr><td>5</td><td>70</td></tr><tr><td>10</td><td>440</td></tr></tbody></table>
