The following algorithm determines <D>, the submonoid of a given monoid M generated by a given subset D. We shall use the notation xN for {xn | n N}.