class Pattern
{
static void Main()
{
int row, space, n, coll;
Console.WriteLine("Enter the
number of rows : ");
n = int.Parse(Console.ReadLine());
for (row = 0; row <= n; row++)
{
Console.Write(" ");
for (space = 1; space <= (n - row); space++)
Console.Write(" ");
for (coll = 0; coll <= row; coll++)
Console.Write(factorial(row) / (factorial(coll) * factorial(row - coll))
+ " ");
Console.WriteLine();
}
Console.ReadLine();
}
static int factorial(int n)
{
int c;
int result = 1;
for (c = 1; c <= n; c++)
result = result * c;
return (result);
}
}
No comments:
Post a Comment