HTML & JS
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{

    if(n==1)
    {
        return false;
    }
    else if(n%2 == 0)
     return false;
    else
    {
        for(int i = 3; i*i<=n; i+=2)// naive appraoch
        {
            if(n%i == 0)
            {
               return false;
            }
        }
        return true;
    }
}
int main()
{
    int N;
    cout<<"Enter the upper limit:";
    cin>>N;
    cout<<"Prime numbers between 1 and "<<N<<" are: ";
    for(int i = 1; i<=N; i++)
    {
        if(isPrime(i))
        {
            cout<<i<<" ";
        }
    }
    return 0;
}

Generated URL:

Output:

Enter the upper limit:Prime numbers between 1 and 0 are: 
Report Bug