Fixed mistake in logic calculating prime factors