Laudanum-user

Untitled

Oct 30th, 2022
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. Console.WriteLine("Task: I_1");
  2.  
  3. static int C(uint n, uint k)
  4. {
  5.     int[] factorial = new int[n + 1];
  6.     factorial[0] = 1;
  7.     for (int i = 1; i <= n; i++)
  8.     {
  9.         factorial[i] = i * factorial[i - 1];
  10.     }
  11.     return factorial[n] / (factorial[k] * factorial[n - k]);
  12. }
  13.  
  14. static int solve(uint candidates)
  15. {
  16.     return C(candidates, 5);
  17. }
  18.  
  19. Console.WriteLine("Solve for 8: {0}", solve(8));
  20. Console.WriteLine("Solve for 10: {0}", solve(10));
  21. Console.WriteLine("Solve for 11: {0}", solve(11));
  22.  
Add Comment
Please, Sign In to add comment