title: pascal's Triangle implementation
body: <p>I am trying to make a program for pascal's triangle,the formaula to calculate the <code>rth</code> value in <code>nth</code> row is <code>n!/r!(n-r)!</code></p>
  
  <p>I've been tring to implement it like this:</p>
  
  <pre><code>          #include &lt;iostream&gt;     // std::cout, std::endl
            #include &lt;iomanip&gt;      // std::setw
            int Pascal(int ,int );
            int Factorial( int);
            int main () 
            {
             int n=0;//Number of rows in the triangle
             for(int i=12;i&gt;0;i--)
              {
                std::cout &lt;&lt; std::setw(i)&lt;&lt;std::endl;
                for (int j=1;j&lt;12-i;j++)
                 {
                  int r=0; //rth element initialized for each row
                  int P= Pascal(r,n);
                  std::cout &lt;&lt; P ;
                  std::cout &lt;&lt;std::setw(2);
                  r=r+1;
                 }
  
                n=n+1;
  
             }
                 std::cout&lt;&lt;std::endl;
                     return 0;
             }
             int Pascal(int r,int n)
             {
                 int d = n-r; ///Difference of n with r
                 int f1; ///factorial of n
                 int f2; ///factorial of r
                 int f3; ///factorial of (n-r)
  
                 f1=Factorial(n);
                 f2=Factorial(r);
                 f3=Factorial(d);
                 return f1/(f2*f3);
  
             }
             int Factorial( int begin )
             {
                     int F;
                     if ( begin == 0 )
                     {
                      return 1; 
                     }
                     else
                     {
                       F= begin*Factorial(begin-1);
                     }
                return F;         
               }
  </code></pre>
  
  <p>but somehow I am getting this output:</p>
  
  <pre><code>                   1
                    1 1
                   1 1 1
                  1 1 1 1
                 1 1 1 1 1
                1 1 1 1 1 1
               1 1 1 1 1 1 1
              1 1 1 1 1 1 1 1
             1 1 1 1 1 1 1 1 1
            1 1 1 1 1 1 1 1 1 112
  </code></pre>
  
  <p>Could someone guide me where am I going wrong?</p>