Sigma Testing Problem

The Bug

The most naive approach to solving the problem is to check every potential factor from 1 to N, adding in those that divide N evenly.  A more efficient approach checks potential factors only up to the square root of N, adding in both the factor, f, and its complement N/f.  The danger with this approach is that if N is a perfect square, then its square root may be added in twice, rather than once as would be appropriate.  This is indeed the bug in the testing program and testing any perfect square in the valid range would expose the bug.