is 33 prime number
33 is prime
find is number prime
int number;
cin >> number;
if (number == 2) {
cout << "Prime" << endl;
return;
}else if(number == 1 || number % 2 == 0){
cout << "Not prime" << endl;
return;
}
for (int i = 3; i * i <= number; i+=2) {
if(number % j == 0){
cout << "Not prime" << endl;
return;
}
}
cout << "Prime" << endl;
return;
program to know if a number is prime
#include<bits/stdc++.h>
using namespace std;
bool Is_Prime(long long x){
if(x%2==0)return false;
for(int i=3;i*i<=x;i+=2)
if(x%i==0)return false;
return true;
}
int main(){
long long x;
cin>>x;
if(Is_Prime(x))cout<<"Is Prime";
else cout<<"Is not Prime";
}
verify a prime number
function isPrime(n){
var divisor = 2;
while (n > divisor){
if(n % divisor == 0){
return false;
}
else
divisor++;
}
return true;
}
> isPrime(137);
= true
> isPrime(237);
= false
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us