Advertisement
danzylrabago

PascalTriangle

Mar 25th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. public class SolutionClass{
  2. public void PascalTriangle(int row){
  3. int col = 1;
  4.  
  5. for(int i = 0 ;i < row; i++)
  6. {
  7. for(int space = 1; space <= row-i; space++)
  8. Console.Write(" ");
  9. for(int j = 0; j <=i; j++)
  10. {
  11. if (j==0||i==0)
  12. col = 1;
  13. else
  14. col = col * (i-j+1)/j;
  15. Console.Write("{0} ",col);
  16. }
  17. Console.WriteLine();
  18. }
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement