handles squares & corrected a bug: when one of the prime numbers was at the end of the seq