Skip to content

Instantly share code, notes, and snippets.

@ChrisLeNeve
Created October 14, 2019 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisLeNeve/5fafd10322ba89016b646e296f986595 to your computer and use it in GitHub Desktop.
Save ChrisLeNeve/5fafd10322ba89016b646e296f986595 to your computer and use it in GitHub Desktop.
Project euler problem 7 - take 1
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
class Scratch {
public static void main(String[] args) {
System.out.println(solution());
}
private static int solution() {
List<Integer> primes = new ArrayList<>();
int start = 2;
while (primes.size() <= 10001) {
BigInteger bigIntValue = BigInteger.valueOf(start);
if (bigIntValue.isProbablePrime(5)) {
primes.add(start);
}
start++;
}
return primes.get(10001);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment