Advertisement
oxguy3

pascals triangle

Mar 3rd, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. package org._7hills.schifhay14.apcs;
  2.  
  3. /**
  4.  * @author Hayden Schiff
  5.  * @version March 3, 2014
  6.  * @assign.ment APCS Ch. 8 Recursion problems
  7.  * @descrip.tion Programming Project #8.9
  8.  *
  9.  * Generates the Nth line of a Pascal's Triangle
  10.  */
  11.  
  12. public class PascalsTriangle {
  13.  
  14.     public static void main(String[] args) {
  15.        
  16.     }
  17.    
  18.     public static int[] getTriangleRow(int row) {
  19.         if (row==1) {
  20.             int[] theRow = {1};
  21.             return theRow;
  22.         }
  23.         if (row==2) {
  24.             int[] theRow = {1, 1};
  25.             return theRow;
  26.         }
  27.         if (row==3) {
  28.             int[] theRow = {1, 2, 1};
  29.             return theRow;
  30.         }
  31.        
  32.         int[] rowAbove = getTriangleRow(row-1);
  33.         int[] theRow = new int[row];
  34.         for (int i = 0; i < theRow.length; i++) {
  35.            
  36.         }
  37.        
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement