Untitled

mail@pastecode.io avatar
unknown
csharp
2 months ago
1.0 kB
5
Indexable
Never
using System;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Введите X: ");
            double X = double.Parse(Console.ReadLine());

            Console.Write("Введите Y: ");
            double Y = double.Parse(Console.ReadLine());

            Console.Write("Введите N: ");
            double N = double.Parse(Console.ReadLine());

            double result = 0;

            for (int i = 0; i < N; i++)
            {
                if (i % 2 == 0)
                {
                    double term = Math.Pow(X - Y, 2 * i) / ((2 * i + 1) * (2 * i + 3) * 1);
                    result += term;
                } else
                {
                    double term = Math.Pow(X - Y, 2 * i) / ((2 * i + 1) * (2 * i + 3) * -1);
                    result += term;
                }
            }

            Console.WriteLine($"Результат: {Math.Round(result, 2)}");
        }
    }
}
Leave a Comment