Skip to content

Instantly share code, notes, and snippets.

@azdafirmansyah
Created November 30, 2017 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azdafirmansyah/6c610e89b2dc90d11c7399fec71c6091 to your computer and use it in GitHub Desktop.
Save azdafirmansyah/6c610e89b2dc90d11c7399fec71c6091 to your computer and use it in GitHub Desktop.
Check Prime Number
'''
Exercise URL : http://www.practicepython.org/exercise/2014/04/16/11-check-primality-functions.html
Ask the user for a number and determine whether the number is prime or not.
(For those who have forgotten, a prime number is a number that has no divisors.)
'''
def check_primary(num):
result = True
for j in range(2,num):
if num % j == 0:
result = False
return result
input_num = int(input("Input Prime to Show : \n > "))
list_primary = []
for i in range(2,input_num):
result = check_primary(i)
if result:
list_primary.append(i)
print(list_primary)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment