Advertisement
ibakyrdjiev

Untitled

Jul 9th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3.  
  4. class CatalanNumbers
  5. {
  6.     static void Main()
  7.     {
  8.         int n = 5;
  9.         int DoubleN = n * 2;
  10.         int nPlus1 = n + 1;
  11.         BigInteger factorielN = 1;
  12.         BigInteger factDoubleN = 1;
  13.         BigInteger factNPlus1 = 1;
  14.         BigInteger result = 1;
  15.         for (int i = 1; i <= DoubleN; i++)
  16.         {
  17.             factDoubleN *= i;
  18.             if (nPlus1 >= i)
  19.             {
  20.                 factNPlus1 *= i;
  21.                 if (n >= i)
  22.                 {
  23.                     factorielN *= i;
  24.                 }
  25.                 else
  26.                 {
  27.                     continue;
  28.                 }
  29.             }
  30.             else
  31.             {
  32.                 continue;
  33.             }
  34.         }
  35.         result = factDoubleN / ((factNPlus1) * factorielN);
  36.         Console.WriteLine(result);
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement