in Python by
Q:
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
Click here to read more about Python
Click here to read more about Insurance

Related questions

+1 vote
asked Feb 18 in Linux by SakshiSharma
0 votes
asked Jun 8, 2020 in HDFS by Robindeniel
0 votes
asked Jan 27, 2020 in JAVA by rahuljain1
+2 votes
asked Jul 28, 2019 in R Language by Aarav2017
+1 vote
asked Feb 15 in Python by SakshiSharma
...