Pietras286

Dwumiany

Dec 13th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. namespace Problem22
  2. {
  3.     class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             int t = int.Parse(Console.ReadLine());
  8.             for (int i = 0; i < t; i++)
  9.             {
  10.                 string[] tab = Console.ReadLine().Split(' ');
  11.                 double n = double.Parse(tab[0]);
  12.                 double k = double.Parse(tab[1]);
  13.                 Console.WriteLine(Newton(n, k));
  14.             }
  15.         }
  16.  
  17.         private static double Newton(double n, double k)
  18.         {
  19.             double wynik = 1;
  20.             for (int i = 1; i <= k; i++)
  21.             {
  22.                 wynik = (wynik * (n - i + 1)) / i;
  23.             }
  24.             return Math.Round(wynik);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment