Created
February 1, 2017 02:50
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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