TheBulgarianWolf

Pascal's triangle

Oct 17th, 2020
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics.CodeAnalysis;
  4. using System.Linq;
  5. using System.Numerics;
  6.  
  7. namespace SoftuniExercisesWithVariables
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             Console.WriteLine("Enter the number of rows: ");
  15.             int rows = int.Parse(Console.ReadLine());
  16.             int cols = rows;
  17.             for(int i = 1; i < rows; i++)
  18.             {
  19.                 int num = 1;
  20.                 for(int l = 0; l <= i; l++)
  21.                 {
  22.                     Console.Write("   {0:D} ", num);
  23.  
  24.                     num = num * (i - l) / (l + 1);
  25.                 }
  26.                 Console.WriteLine();
  27.                 Console.WriteLine();
  28.             }
  29.         }
  30.     }
  31. }
  32.  
Add Comment
Please, Sign In to add comment