0 votes
in Python by
Write a program to check whether the given number is prime or not?

1 Answer

0 votes
by
The code to check prime number is as follows:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

# program to check the number is prime or not

n1 = 409

# num1 = int(input("Enter any one number: "))

# prime number is greater than 1

if n1 > 1:

# check the following factors

for x is in range of(2,num1):

if (n1 % x) == 0:

print(n1,"is not a prime number")

print(x,"times",n1//x,"is",num)

break

else:

print(n1,"is a prime number")

# if input number is smaller than

# or equal to the value 1, then it is not prime number

else:

print(n1,"is not a prime number")

Output:

409 is a prime number

Related questions

0 votes
asked Sep 7, 2022 in Python by sharadyadav1986
0 votes
asked May 24, 2020 in Python by SakshiSharma
...