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.
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- "<" could not be used for integer) but i dont know what to use instead of it..while(PrimeFactor < number){
I will be grateful for your help.