Solution (source code)

= Solution

The pointer argument must be passed by reference, because it is replaced:

``
procedure Lengthen(var n: number)
    old := n
    L := len(old)
    new(result, 2*L)
    for i := 0 to L-1 do
        result[i] := old[i]
    for i := L to 2*L-1 do
        result[i] := 0
    n := result
``

The low-order coefficients are preserved and the newly allocated high-order coefficients are zero, so the <digit-array integer representation> has the same value. The allocation remains nonempty because $L\geq1$. Neither allocation nor an uninitialized high-order cell may be assumed to contain zero. Any other reference to the old array still denotes that old array; the code does not free storage through an alias.