Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

prime number in python

def prime_number(n):
    c = 0
    for x in range(2, n):
        if n % x == 0:
            c = c + 1
    return c


n = int(input("Enter a number = "))
if prime_number(n) == 0:
    print("Prime number.")
else:
    print("Not prime number.")
 
PREVIOUS NEXT
Tagged: #prime #number #python
ADD COMMENT
Topic
Name
2+8 =