Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

primes in python

from math import sqrt
for i in range(2, int(sqrt(num)) + 1):
    if num % i == 0:
        print("Not Prime")
        break
    print("Prime")

# Note: Use this if your num is big (ex. 10000 or bigger) for efficiency
# The result is still the same if the num is smaller
 
PREVIOUS NEXT
Tagged: #primes #python
ADD COMMENT
Topic
Name
1+5 =