Pascal's triangle: Difference between revisions

Line 376:
//work on the next row
ArrayList<Integer> thisRow= new ArrayList<Integer>();
thisRow.add(1last.get(0)); //beginning
for(int j= 1;j < i;++j){//loop the number of elements in this row
//sum from the last row
thisRow.add(last.get(j - 1) + last.get(j));
}
thisRow.add(1last.get(i)); //end
last= thisRow;//save this row
System.out.println(thisRow);
Anonymous user