Last active
November 8, 2018 19:24
-
-
Save daniilgri/8e373f838360769c9ebe575af1ed5743 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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