Skip to content

Instantly share code, notes, and snippets.

@shamikalashawn
Created February 1, 2017 02:50
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 shamikalashawn/be115dd12e0ecdcb95bffd70e32fe7c7 to your computer and use it in GitHub Desktop.
Save shamikalashawn/be115dd12e0ecdcb95bffd70e32fe7c7 to your computer and use it in GitHub Desktop.
Two functions for the price of one! First a function that returns True for prime numbers. Second, a function that takes a number and prints all the primes up to and including that number.
def is_prime(number):
if number <=1:
return False
else:
for num in range(2, number):
if (number % num == 0) and (number != num):
return False
return True
def prime_finder(num):
for number in range(2, num+1):
if is_prime(number):
print number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment