procedure residue(i, m, j) #: residue for j-based integers /j := 0 i %:= m if i < j then i +:= m return i end