mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-26 06:48:04 +02:00
misc
This commit is contained in:
parent
1cc20da665
commit
b18561fc54
19 changed files with 197 additions and 0 deletions
|
@ -0,0 +1,27 @@
|
|||
/* @author Axel Busch */
|
||||
public class SingleCorePrimeTest {
|
||||
|
||||
public static boolean isPrime(int n) {
|
||||
if (n < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 2; i <= Math.sqrt(n); ++i) {
|
||||
if (n % i == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int target = 10_000_000;
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 2; i <= target; ++i) {
|
||||
isPrime(i);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println(end-start);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue