spiritway,
This is not a general purpose solution. It is addressing a specific mathematical problem that by its definition can't exceed 1000. Normally when I think something is bounded that I have no control over I stipulate that it should not <fill in the blank> and that I would want to know about it if it does.