In step 2 of the RemainderTree algorithm, the variable i should go down to zero, not 1.
(Thanks to Maike Massierer for catching this.)