solving problems 38 and 41