Advertisement
nassss

Untitled

Nov 10th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3.  
  4. namespace _08._CatalanNumbers
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int n = int.Parse(Console.ReadLine());
  11. BigInteger result = 1;
  12. BigInteger numerator = 1;
  13. BigInteger divider = 1;
  14.  
  15. if (n < 0 || n > 100)
  16. {
  17. Console.WriteLine("Invalid number!");
  18. }
  19. else
  20. {
  21.  
  22. for (int k = 2; k <= n; k++)
  23. {
  24. numerator *= n + k;
  25. divider *= k;
  26.  
  27. }
  28. result = numerator / divider;
  29. Console.WriteLine(result);
  30. }
  31.  
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement