## Recusion vs Interation: Linked lists

We are going to continue to look at the linked list example. You should be able to continue from the last lab.

### Incrementing the number

Try to write a method to add 1 to the a digit list using both recursion and iteration.

```    static DigitNode plusplusNumber(DigitNode d)
```

Continue on the problem of adding number. This one is tricky because the numbers may not be the same length.

```    static DigitNode addNumbers(DigitNode a, DigitNode b)
```

### Testing it out

This is the program I used to test my results.

```    public static void main(String[] args) {
DigitNode listNum = createLSBFirst(1123979876876124L) ;
DigitNode incNum = createLSBFirst(12345678999999L) ;
DigitNode nineNum = createLSBFirst(9) ;
DigitNode nineninesNum = createLSBFirst(999999999) ;

System.out.println(printNumber(listNum)) ;
System.out.println(printNumber(plusplusNumber(listNum))) ;
System.out.println(printNumber(plusplusNumberIter(listNum))) ;

System.out.println(printNumber(incNum)) ;
System.out.println(printNumber(plusplusNumber(incNum))) ;
System.out.println(printNumber(plusplusNumberIter(incNum))) ;

System.out.println(printNumber(nineNum)) ;
System.out.println(printNumber(plusplusNumber(nineNum))) ;
System.out.println(printNumber(plusplusNumberIter(nineNum))) ;

System.out.println(printNumber(nineninesNum)) ;
System.out.println(printNumber(plusplusNumber(nineninesNum))) ;
System.out.println(printNumber(plusplusNumberIter(nineninesNum))) ;