public static IntList addEmUp(IntList N1, IntList N2, int c) { if (N2 == null) { if (N1 == null) { if (c== 0) { return null ; } else { return new IntList(1, null) ; } } else { if (c==0) { return N1 ; } else { return addEmUp(null, N1, c) ; } } } else /* N2 != null */ { int loD1 ; // low digit of N1 int loD2 ; // low digit of N2 IntList hiN1 ; // high digits of N1 IntList hiN2 ; // high digits of N2 if (N1 == null) { loD1 = 0 ; hiN1 = null ; } else { loD1 = N1.getItem() ; hiN1 = N1.getNext() ; } loD2 = N2.getItem() ; hiN2 = N2.getNext() ; int cOut = (loD1 + loD2 + c)/10 ; int sOut = (loD1 + loD2 + c)%10 ; IntList upperPart = addEmUp(hiN1, hiN2, cOut) ; return new IntList(sOut, upperPart) ; } }