//
// main.cpp
// Pascal Triangle
//
// Created by Himanshu on 20/09/21.
//
#include <iostream>
using namespace std;
void printPascalTriangle (int n) {
//Base case
cout<<"1"<<endl;
for (int i=1; i<n; i++) {
int C = 1;
for (int j=0; j<=i; j++) {
cout<<C<<" ";
//We are using (i-j) instead of (i-(j-1)) because
//calculation is for next or (j+1)th element
C = C * (i-j)/(j+1);
}
cout<<endl;
}
}
int main() {
int n = 7;
printPascalTriangle (n);
return 0;
}
Ly8KLy8gIG1haW4uY3BwCi8vICBQYXNjYWwgVHJpYW5nbGUKLy8KLy8gIENyZWF0ZWQgYnkgSGltYW5zaHUgb24gMjAvMDkvMjEuCi8vCgojaW5jbHVkZSA8aW9zdHJlYW0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgoKdm9pZCBwcmludFBhc2NhbFRyaWFuZ2xlIChpbnQgbikgewogICAgCiAgICAvL0Jhc2UgY2FzZQogICAgY291dDw8IjEiPDxlbmRsOwogICAgCiAgICBmb3IgKGludCBpPTE7IGk8bjsgaSsrKSB7CiAgICAgICAgaW50IEMgPSAxOwogICAgICAgIGZvciAoaW50IGo9MDsgajw9aTsgaisrKSB7CiAgICAgICAgICAgIAogICAgICAgICAgICBjb3V0PDxDPDwiICI7CiAgICAgICAgICAgIC8vV2UgYXJlIHVzaW5nIChpLWopIGluc3RlYWQgb2YgKGktKGotMSkpIGJlY2F1c2UKICAgICAgICAgICAgLy9jYWxjdWxhdGlvbiBpcyBmb3IgbmV4dCBvciAoaisxKXRoIGVsZW1lbnQKICAgICAgICAgICAgQyA9IEMgKiAoaS1qKS8oaisxKTsKICAgICAgICB9CiAgICAgICAgY291dDw8ZW5kbDsKICAgIH0KICAgIAp9CgppbnQgbWFpbigpIHsKICAgIGludCBuID0gNzsKICAgIHByaW50UGFzY2FsVHJpYW5nbGUgKG4pOwogICAgcmV0dXJuIDA7Cn0=