wingman007 icon

KrushkovTask122bIterNextMember

wingman007 | PRO | 11/06/25 09:51:53 AM UTC (Edited) | 0 ⭐ | 679 👁️ | Never ⏰ | []
C# |

830 B

|

Software

|

0 👍

/

0 👎

using System;
 
class Program
{
    static void Main()
    {
        Console.Write("Въведете x: ");
        double x = double.Parse(Console.ReadLine());
 
        double eps;
        do
        {
            Console.Write("Въведете eps (напр. 0.0001): ");
            eps = double.Parse(Console.ReadLine());
        } while (eps <= 0 || eps >= 1);
 
        double term = x;     // първи член: x
        double sum = term;   // натрупана сума
        int n = 0;
 
        while (Math.Abs(term) >= eps)
        {
            n++;
            term *= -1 * x * x / ((2 * n) * (2 * n + 1));
            sum += term;
        }
 
        Console.WriteLine($"Резултат y = {sum}");
        Console.WriteLine($"Контролна стойност Math.Sin(x) = {Math.Sin(x)}");
    }
}
 

Comments