#include <iostream>
using namespace std;
int isp(int n)
{
for(int i=2;i<=n/2;i++)
if(n%i==0)
return 0;
return 1;
}
int main()
int n;
cin>>n;
for(int i=2;i<=n;i++)
if(isp(i))
cout<<i<<" ";
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
#include <iostream>
using namespace std;
int isp(int n)
{
for(int i=2;i<=n/2;i++)
if(n%i==0)
return 0;
return 1;
}
int main()
{
int n;
cin>>n;
for(int i=2;i<=n;i++)
if(isp(i))
cout<<i<<" ";
return 0;
}