Pagini recente » Cod sursa (job #1781638) | Cod sursa (job #1145450) | Cod sursa (job #904555) | Cod sursa (job #64589) | Cod sursa (job #1443805)
import java.io.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws FileNotFoundException{
final int nmx = 2000005;
int n, suma = 0;
boolean viz[] = new boolean[nmx];
Scanner reader = new Scanner(new FileInputStream("ciur.in"));
n = reader.nextInt();
reader.close();
for(int i = 2; i <= n; ++i)
if(viz[i] == false){
++ suma;
for(int j = i + i; j <= n; j += i)
viz[j] = true;
}
PrintWriter writer = new PrintWriter("ciur.out");
writer.write(suma + "\n");
writer.close();
}
}