Created
October 14, 2019 11:53
-
-
Save ChrisLeNeve/5fafd10322ba89016b646e296f986595 to your computer and use it in GitHub Desktop.
Project euler problem 7 - take 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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