1#include <iostream>
2using namespace std;
3
4int main()
5{
6 int n, i;
7 bool isPrime = true;
8
9 cout << "Enter a positive integer: ";
10 cin >> n;
11
12 for(i = 2; i <= n / 2; ++i)
13 {
14 if(n % i == 0)
15 {
16 isPrime = false;
17 break;
18 }
19 }
20 if (isPrime)
21 cout << "This is a prime number";
22 else
23 cout << "This is not a prime number";
24
25 return 0;
26}
1bool isprime(int n)
2{
3 if(n<=1)
4 return false;
5 for (int i = 2; i <= sqrt(n); i++)
6 if (n % i == 0)
7 return false;
8
9 return true;
10}
1#include<bits/stdc++.h>
2using namespace std;
3bool Is_Prime(long long x){
4 if(x%2==0)return false;
5 for(int i=3;i*i<=x;i+=2)
6 if(x%i==0)return false;
7 return true;
8}
9int main(){
10 long long x;
11 cin>>x;
12 if(Is_Prime(x))cout<<"Is Prime";
13 else cout<<"Is not Prime";
14}