Task: An integer N is given (entered from the keyboard). Calculate the amount from n terms:

```
# define _crt_secure_no_warnings
#Include & lt; iostream & gt;
#Include & lt; math.h & gt;
#Include & lt; stdlib.h & gt;
#Include & lt; malloc.h & gt;
INT MAIN () {
SETLOCALE (LC_ALL, "RUS");
int n, y = 1, m = 0;
Printf ("Enter N:"); Scanf ("% d", & amp; n);
While (N! = 0) {// Factorial
y = y * n;
n = n - 1;
}
While (N! = 0) {// Danger
m = m + ((n + n + 1) * (n + n + 1));
n = n - 1;
}
PrintF ("% d", y);
PrintF ("\ N% d", m);
}
```

So far, I just do the sketch, I encountered a problem that it displays m = 0 and it does not change. What could be a mistake? I do the addition M + some number.

## Answer 1, Authority 100%

just carefully write down all the steps (ideone ).

When calculating SUs, you can use the formula, well, okay.

```
int n, last = 0, f = 1;
Printf ("Enter N:"); Scanf ("% d", & amp; n);
Double Res = 0;
For (int i = 1; i & lt; = n; i ++) {
f * = i;
int sum = 0;
for (int k = last + 1; k & lt; = last + i; k ++)
SUM + = K;
Last + = i;
res + = 1.0 * F / (SUM * SUM);
}
Printf ("% F", RES);
```

## Answer 2, Authority 100%

```
unsigned int n;
Scanf ("% u", & amp; n);
Double TERM = 1.0, SUM = 1.0;
For (unsigned int k = 2; k & lt; = n; ++ k)
{
double a = k - 3. + (3. * k + 1.) / (k * k + 1.);
SUM + = TERM * = A * A / K;
}
Printf ("%. 10LF \ N", SUM);
```

Full code here .

## Answer 3, Authority 50%

You are in the `While `

cycle: reduce `n `

to zero because of this, the second cycle `While `

is simply not performed.

Solve this by creating an additional variable, and in the cycles to use another, although the factorial calculation will be carried out in a separate function