1import math
2def isPrimeNumber(n):
3 if (n < 2):
4 return False;
5 sq = int(math.sqrt(n))
6 for i in range(2, sq + 1):
7 if (n % i == 0):
8 return False
9 return True
1# Program to check if a number is prime or not
2
3#too take the input from user use "num: int = int(input('Give the value of num '))"
4num: int = int(input('Give the value of Num: '))
5
6# define a variable felix
7felix = False
8
9# prime numbers are greater than 1
10if num > 1:
11 # check for factors
12 for i in range(2, num):
13 if (num % i) == 0:
14 # if factor is found, set flag to True
15 felix = True
16 # break out of loop
17 break
18
19# check if flag is True
20if felix:
21 print(num, "is not a prime number")
22else:
23 print(num, "is a prime number")
1from math import sqrt
2for i in range(2, int(sqrt(num)) + 1):
3 if num % i == 0:
4 print("Not Prime")
5 break
6 print("Prime")
7
8# Note: Use this if your num is big (ex. 10000 or bigger) for efficiency
9# The result is still the same if the num is smaller