Anonymous user
Pascal's triangle: Difference between revisions
→Summing from Previous Rows
Line 376:
//work on the next row
ArrayList<Integer> thisRow= new ArrayList<Integer>();
thisRow.add(
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(
last= thisRow;//save this row
System.out.println(thisRow);
|