prime no

#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";
}

3.6
5
Steve Paff 65 points

                                    //JAVA Program to check whether the number entered by user is Prime or not.import java.util.Scanner;public class prime{                                                               //class declaration        public static void main(String[] args)	{	                                                //main method declaration                Scanner sc=new Scanner(System.in);              //scanner class object creation		System.out.println(&quot;Enter a number&quot;);		int n = sc.nextInt();			        //taking a number n as input		int count=0;		for(int i = 1 ; i &lt;=n ; i++)			{				if(n % i == 0)				//condition for getting the factors of number n			count=count+1;		}		if(count == 2)		                        //if factors are two then, number is prime else not		System.out.println(&quot;Prime Number&quot;);		else		System.out.println(&quot;Not a Prime Number&quot;);		sc.close();		                        //closing scanner class(not mandatory but good practice)	}                                                       //end of main method}                                                               //end of class

3.6 (5 Votes)
0
3.87
7
Levi P. 80 points

                                      28

3.87 (23 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source