Mai intai trebuie sa te autentifici.
Cod sursa(job #3295974)
Utilizator | Data | 10 mai 2025 12:17:23 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n;
int vf[105];
int main()
{
fin >> n;
for(int i = 2; i * i <= n; i ++)
{
if(vf[i] == 0)
for(int j = i * i; j <= n; j += i)
{
vf[j] = 1;
}
}
for(int i = 2; i <= n; i ++)
{
if(vf[i] == 0)
cout << i << ' ';
}
return 0;
}