Solution for problems 18 and 67