It's only one if-then, and this is Pascal. It's not like there's a loop, which is surely the bigger problem.

Anyway, my solution is off-by-one on a couple of points in the problem space. Ignore it anyway.
_________________________
-- roger