Advertisement
Guest User

test 3 zad 3 1 grupa

a guest
Feb 24th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             enterA:
  6.             Console.Write("Enter a: ");
  7.             int a = int.Parse(Console.ReadLine());
  8.             if (a <= 0)
  9.             {
  10.                 goto enterA;
  11.             }
  12.  
  13.             enterB:
  14.             Console.Write("Enter b: ");
  15.             int b = int.Parse(Console.ReadLine());
  16.             if (b <= 0)
  17.             {
  18.                 goto enterB;
  19.             }
  20.  
  21.             Console.WriteLine(F(a + b) * F(Math.Abs(a - b)));
  22.         }
  23.  
  24.         private static double F(int n)
  25.         {
  26.             double sum = 1;
  27.             for (int i = 2; i <= n; i++)
  28.             {
  29.                 sum += (1 / Math.Pow(i, 4));
  30.             }
  31.  
  32.             return sum;
  33.         }
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement