c 2b 2b check prime

Solutions on MaxInterview for c 2b 2b check prime by the best coders in the world

showing results for - "c 2b 2b check prime"
Cristian
03 Jun 2018
1#include <bits/stdc++.h>
2
3using namespace std;
4
5int main()
6{
7    int prime;
8    cin >> prime; // input should be greater then 0
9    bool is_prime = true;
10
11    for (int i = 2; i * i <= prime; i++)
12    {
13        if (prime % i == 0)
14        {
15            is_prime = false;
16            break;
17        }
18    }
19
20    if (is_prime)
21    {
22        cout << "Prime number" << endl;
23    }
24    else
25    {
26        cout << "Not Prime number" << endl;
27    }
28    return 0;
29}
queries leading to this page
c 2b 2b check primec 2b 2b check prime