**Question** Write a Python program to check if the number is prime or not?

**Answer:** Example to check whether an integer is a prime number or not.

1 2 3 4 5 6 7 8 9 | n= int(input( "enter the number that has to be checked:")) a=0 for i in range(2,int((n/2))): if(n%i ==0): //finding whether the number has a factor or not a=a+1 if(a>1): print("it is not prime number.") else: print("it is prime number.") |

**Output**

1 2 3 4 5 | enter the number that has to be checked:97 it is prime number. enter the number that has to be checked: 54 it is not prime number. |

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

- Get excerpt using get_the_excerpt outside a loop
- How do I sort an NSMutableArray with custom objects in it?
- How to get current year in Java?
- How to find whether a given integer is a power of 3 or not?
- Altering height and width of path in flutter
- How to clone ArrayList and also clone its contents?
- What is metadata rewriting?
- How to get a JavaScript object’s class?
- How to set ANDROID_HOME in MacOS?
- What is the full form of AIT?
- Can’t set state in componentWillMount
- How to dynamically insert script tag that will execute via Reactjs?
- What is Lifting State Up in React?
- How do you get property descriptors of an object?
- InheritedWidget – The getter was called on null after navigator.push

We use cookies to ensure that we give you the best experience and use cookies in order to personalize the advertising that you see on our website. Read more about our Privacy Policy.Got it!