Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
34356 | sunhuifeng | 输出N以内的素数 | C++ | Accepted | 18 MS | 248 KB | 271 | 2023-12-19 21:16:29 |
#include<bits/stdc++.h> using namespace std; int main(){ int n,f; cin>>n; int cnt=0; for (int i=2;i<=n;i++){ f=1; for(int j=2;j<=sqrt(i);j++){ if(i%j==0){ f=0; break; } } if(f){ cout<<i<<endl; } } return 0; }