Mai intai trebuie sa te autentifici.
Cod sursa(job #1451867)
| Utilizator | Data | 18 iunie 2015 19:25:15 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | c | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
bool array[10000000];
int ciur_eratostene(int n){
int p = 0;
for(int i = 2; i <= n; i++)
array[i] = true;
for(int i = 2; i <= n; i++)
if(array[i]){
p++;
for(int j = i + i; j <= n; j += i)
array[j] = false;
}
return p;
}
int main()
{
int n;
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
scanf("%d", &n);
printf("%d", ciur_eratostene(n));
return 0;
}
