Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication16
- {
- class Program
- {
- static void Main(string[] args)
- {
- double tgx = 0;
- Console.WriteLine("Введите x");
- string str = Console.ReadLine();
- int X = int.Parse(str);
- if Tg(X,ref double tgx)
- Console.WriteLine(tgx);
- else Console.WriteLine("ошибка");
- }
- public static double BernulliNumbe(int n)
- {
- if (n == 0)
- return 1;
- if (n % 2 == 1)
- return 0;
- double sum = 0;
- for (int k = 1; k < n + 1; k++)
- {
- sum += (Factorial(n + 1) * BernulliNumbe(n - k)) / (Factorial(k + 1) * Factorial(n - k));
- }
- return (-1.0 / (n + 1)) * sum;
- }
- public static double stepen(double d, int nn)
- {
- double sum1 = 1.0;
- for (int k = 0; k <= nn; k++)
- {
- sum1 = sum1 * d;
- }
- return sum1;
- }
- public static bool Tg(int x, ref double tgx)
- {
- if (x > (-(Math.PI) / 2) && (x < (Math.PI) / 2))
- {
- int n =1;
- double summm=0;
- double Psummm=-100;
- while (summm - Psummm > 0.01)
- {
- Psummm=summm;
- summm+=( (BernulliNumbe(2*n))*(stepen(-4,n))*(1+stepen(-4,n))/((Factorial(2*n))*(stepen(x,2*n-1))));
- n++;
- }
- tgx=summm;
- return true;
- }
- else
- {
- tgx = 0;
- return false;
- }
- }
- public static int Factorial(int numb)
- {
- int res = 1;
- for (int i = numb; i > 1; i--)
- res *= i;
- return res;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement