The largest prime factor of the specific number.

Its my first post, so i would like to say Hello to Java Community. I'am absolutely new in programming and because of my young age(15) i have many problems to understand some aspects of it(especially advanced maths, logical thinking etc.). Nevertheless i think with an appropriate determination I can achieve success in this field of science. Lastly - I live in Poland thereby I could have sometimes problems with correct and "inteligent" english, but I am convinced that with your help my knowledge will rise up.

Coming to the point. Last time i tried to write a simple program which should find the largest prime factor of the number 600851475143.

Code :

import java.util.Arrays;
import java.math.BigInteger;
public class PrimeFactor {
public static void main(String[] args) {
BigInteger[] Array = new BigInteger[i];
BigInteger number = new BigInteger("600851475143");
BigInteger number2 = new BigInteger("0");
BigInteger number3 = new BigInteger("0");
BigInteger PrimeFactor = new BigInteger ("0");
boolean select;
int i = 0;
while(PrimeFactor < number){
PrimeFactor++;
i++;
if(number%PrimeFactor == 0){
PrimeFactor = Array[i];
}
}
BigInteger largest = new BigInteger();
largest = Array[0];
for(int x=1; x<Array.length; x++) largest = max(Array[x],largest);
System.out.println(largest);
}
}

I know that the program has many trivial errors( like there
Code :

while(PrimeFactor < number){

- "<" could not be used for integer) but i dont know what to use instead of it..

I will be grateful for your help.

Re: The largest prime factor of the specific number.

Welcome to the forum

Where exactly are you stuck?

Re: The largest prime factor of the specific number.

Hello.

I hope you understand the two core terms in your problem "prime" and "factor".

If yes then what is your strategy to find the largest prime factor of a given number? In your code you are not checking for if a factor is prime or not?

Use the tips below to write an efficient program:

- The largest prime factor of a given number 'n' is always <= 'n/2'.

- And you may be okay if you use long instead of bigint.

Syed.

Re: The largest prime factor of the specific number.

Don't by shy about your English. It's better than I've seen from most of the native speakers. Just be sure to describe specifically what you need help with and ask specific question. We've learned that it's a waste of time to guess and offer advice about something the poster understands perfectly.