wingman007

KrushkovTask122bIterNextMember

Nov 6th, 2025 (edited)
724
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | Software | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("Въведете x: ");
  8.         double x = double.Parse(Console.ReadLine());
  9.  
  10.         double eps;
  11.         do
  12.         {
  13.             Console.Write("Въведете eps (напр. 0.0001): ");
  14.             eps = double.Parse(Console.ReadLine());
  15.         } while (eps <= 0 || eps >= 1);
  16.  
  17.         double term = x;     // първи член: x
  18.         double sum = term;   // натрупана сума
  19.         int n = 0;
  20.  
  21.         while (Math.Abs(term) >= eps)
  22.         {
  23.             n++;
  24.             term *= -1 * x * x / ((2 * n) * (2 * n + 1));
  25.             sum += term;
  26.         }
  27.  
  28.         Console.WriteLine($"Резултат y = {sum}");
  29.         Console.WriteLine($"Контролна стойност Math.Sin(x) = {Math.Sin(x)}");
  30.     }
  31. }
  32.  
Add Comment
Please, Sign In to add comment