Pascal's triangle: Difference between revisions

Content added Content deleted
(→‎Summing from Previous Rows: now it will work for rows = 0)
(→‎Summing from Previous Rows: initial "last" is never used)
Line 341: Line 341:
if(rows < 0) return;
if(rows < 0) return;
//save the last row here
//save the last row here
LinkedList<Integer> last= new LinkedList<Integer>();
LinkedList<Integer> last = null;
last.add(1);//it's row 0...it starts with 1
for(int i= 0;i <= rows;++i){
for(int i= 0;i <= rows;++i){
//work on the next row
//work on the next row