Assignment #5 Pascal's Triangle

due Friday, February 28 (revised)
The assignment is #14 on the webpage

Use the following setup method (do not modify it in any way):
void setup()
{
   int rows = getRows();
   while (rows != 0)
   {
      printTriangle(rows);
      rows = getRows();
   }
} 

In addition to the two above methods (printTriangle and getRows) you will need:
long nCr(int n, int r)
and
long factorial(int n)

To print a number so that it takes up a certain number of spaces you can use the method String.format from Java. Suppose a variable x has the value 15. To print it out so that it takes up 4 characters (2 spaces and then the 15) you would do:
print(String.format("%4d", x));

Marking Scheme

____
 21

factorial method                (2)  _____
nCr method                      (2)  _____
getRows method                  (2)  _____
printTriangle method            (2)  _____
correct numbers in triangle     (3)  _____
correct formatting in triangle  (3)  _____
process work                    (3)  _____
comments and readability        (3)  _____
uses correct setup method       (1)  _____