fixing a bug where the factor count was wrong for perfect squares