fixed bug. optimized to only divide by known prime numbers