## Q. Python Program to Check Whether a Number is Prime or not.

Here you will find an algorithm and program in Python programming language to check whether the given number is prime number or not. First let us understand what prime number means.

**Explanation : **A number that is divisible by only and only 1 and itself is known as a Prime Number. For example: - 11 is only divisible by 1, so 11 is prime, while 10 is divisible by 1, 2, and 5 so 10 is not a prime number.

## Prime Number Algorithm

START Step 1 → Take integer variable A Step 2 → Divide the variable A with (A/2 to 2) Step 3 → If A is divisible by any value (A/2 to 2) then it is not prime Step 4 → Else it is prime number STOP

# Python Program to Check Whether a Number is Prime or Not

num = int(input("Enter a positive integer: ")) if num > 1: for i in range(2,num): if (num % i) == 0: print(num,"is not a prime number") break else: print(num,"is a prime number") else: print("Please enter a valid number")

#### Output

Enter a positive integer : 17 17 is a prime number. Enter a positive integer : 25 25 is not a prime number.