I need suggestions on how I can make this code runnable. For example, with this number: 600851475143. It works for smaller numbers. Any suggestions on my code overall would be more than welcome. As a side note, I understand it's Project Euler's policy not to share code to its problems, and thus I just want to be pushed in the right direction and don't want any direct answers. Thanks.
import java.util.List;
import java.util.ArrayList;
public class prime {
public static List<Long> factor2(long n){
    List<Long> list = new ArrayList<>();
    for (long a = 1; a < n; a++){
        for (long b = n; b>1; b--){
            if (a*b==n){
                list.add(a);
                list.add(b);
                a++;
                b--;
            }
            else{
                b--;
            }
        }
    }
    return list;
}
public static List<Long> prime (long n){
    List<Long>list = factor2(n);
    List<Long>listPrime = new ArrayList<>();
    for (long x : list){
        if (factor2(x).size()==2){
            listPrime.add(x);
        }
    }
    return listPrime;
}
public static long largestPrime (long n){
    long largest = 1;
    for (long x : prime(n)){
        if (x>largest){
            largest = x;
        }
    }
    return largest;
}
public static void main (String[] args){
    System.out.println(largestPrime(6));
}
}