#include<bits/stdc++.h>
using namespace std;

bool isPrime(int x)
{
    if(x==2)
    {
        return true;
    }
    if(x<2 || x%2==0)
    {
        return false;
    }
    for(int i=3; i<=sqrt(x);i+=2)
    {
        if(x%i==0)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    for(int i=2;i<=100;i++)
    {
       if(isPrime(i)==true)
       {
         cout<<i<<" ";
       }
    }
    cout<<endl;
    return 0;
}

1 comments

  • 1

Information

ID
271
Time
1000ms
Memory
256MiB
Difficulty
7
Tags
# Submissions
135
Accepted
30
Uploaded By