Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Решето Эратосфена
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { int maxN = 100_000; int[] primes = new int[10_000]; int primesCount = 0; for (int i = 2; i <= maxN; i++) { int maxDiv = (int) Math.sqrt(i); boolean isPrime = true; for (int divIndex = 0; primes[divIndex] <= maxDiv && divIndex < primesCount; divIndex++) if (i % primes[divIndex] == 0) { isPrime = false; break; } if (isPrime) primes[primesCount++] = i; } System.out.println(primesCount + ": " + primes[primesCount - 1]); } }
run
|
edit
|
history
|
help
0
OBF-7 4
AVL-GO-FLAT
1(D).
Basic Matrix
Coding Challenge - 04 (Perfect numbers)
h
Coding Challenge - 01 (Even numbers)
Tree_inorder_recursive
Dynamic Array
Sum of EVEN and ODD nubmers (11 grade)