Cod sursa(job #3295975)

Utilizator crististanciu15Stanciu Cristian crististanciu15 Data 10 mai 2025 12:18:20
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.44 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;
            }
    }
    int k = 0;
    for(int i = 2; i <= n; i ++)
    {
        if(vf[i] == 0)
            k++;
    }
    cout << k;
    return 0;
}