pgm 13.10, naive code-intensive version