Submission

Status:
PPPPPPPPPP

Score: 100

User: sorawit

Problemset: จำนวนเฉพาะ (2560)

Language: cpp

Time: 0.004 second

Submitted On: 2024-10-15 16:05:46

#include <bits/stdc++.h>
using namespace std;
vector<int> a;
bool prime(int x){
    if(x<2) return false;
   for(int i=2;i*i<=x;i++){
        if(x % i ==0) return false;
   }
   return true;
}
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    int n;
    cin>>n;
   for(int i=2;i<n;i++){
    if(prime(i)){
        a.push_back(i);
    }
   }
   
   while (!a.empty())
   {
     cout << a.front() << "\n";  
        a.erase(a.begin()); 
   }
   
}