what is java’s prime factor?

Two things are wrong:

  1. You start by testing for factor 3, which means you’ll never find 2 factors.

  2. Your loop’s condition – testFactor > 1 – is wrong. testFactor keeps growing, so the loop will only terminate when testFactor overflows to a negative value. You should terminate when NumberToFactor becomes 1. i.e. change the condition to NumberToFactor > 1.

Oh, and there’s another issue – Factors seems to be a constructor, but it appears inside a class of a different name – factorClass. The constructor must have the same name as the class.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top