Skip to content

Instantly share code, notes, and snippets.

@daniilgri
Last active November 8, 2018 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniilgri/8e373f838360769c9ebe575af1ed5743 to your computer and use it in GitHub Desktop.
Save daniilgri/8e373f838360769c9ebe575af1ed5743 to your computer and use it in GitHub Desktop.
#include "pch.h"
#include <stdio.h>
#include <windows.h>
#include <math.h>
double myFact(int n);
int main()
{
SetConsoleOutputCP(1251);
SetConsoleCP(1251);
float x;
float first;
int m;
double bottom, sum = 0, fac;
printf("Введите x и m: \n");
scanf_s("%f%i", &x, &m);
for (int n = 3; n <= m + 3; n++) {
first = pow(x, n + 2);
printf("First: %.30f \n", first);
fac = myFact(2 * n - 3);
printf("fac: %.f \n", fac);
bottom = exp(x) + x;
printf("bottom: %f \n", bottom);
sum += first * fac / bottom;
printf("Промеж. сумма: %.20f \n", sum);
}
printf("Сумма: %.20f \n", sum);
return 0;
}
double myFact(int n) {
double result = 1;
if (n == 0) { return result; }
for (int i = 1; i <= n; i++)
{
result *= i;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment