HTML & JS
#include<bits/stdc++.h>
using namespace std;
//driver code
int main()
{
    int N;
    cout<<"Enter input:";
    cin>>N;
    bool prime = true; // intially we assume the number is prime
    // loop from 2 to N-1
    for( int itr = 2; itr < N; itr++)
    {
        if(N % itr == 0)
        {
            prime = false;
            break;
        }
    }
    if(prime)
    {
        cout<<N<<" "<<"is a prime number";
    }
    else
    {
        cout<<N<<" "<<"is not a prime number";
    }
}

Generated URL:

Output:

Enter input:0 is a prime number
Report Bug