Last active
November 8, 2018 19:27
-
-
Save daniilgri/4870c69ddeb85c7b54d1ac964735dafd 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() | |
{ | |
double x, sum = 0, ctg, min, fac; | |
SetConsoleOutputCP(1251); | |
SetConsoleCP(1251); | |
printf("Введите x:\n"); | |
scanf_s("%f", &x); | |
for (int k = 1; k <= 8; k++) { | |
min = pow(-1, k); | |
printf("(-1)^k = %f\n", min); | |
ctg = 1 / pow(tan(x), k + 1); | |
printf("ctg = %f\n", ctg); | |
fac = myFact(k * 3); | |
printf("Факториал: %.f \n", fac); | |
printf("Формула: %.30f\n", min*ctg / fac); | |
sum += min * ctg / fac; | |
printf("Промеж. сумма: %.20f \n", sum); | |
} | |
printf("Сумма: %.20f", 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