Created
February 4, 2017 06:51
-
-
Save Akash-Ansari/2c83d93b1a451a78c70ab437635551df to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Printing prime numbers upto a certain number | |
def is_prime(num): | |
for i in range(2, num): | |
if (num % i) == 0: | |
return False | |
return True | |
def getPrimes(max_num): | |
list_of_primes = [] | |
for num in range(2, max_num): | |
if is_prime(num): | |
list_of_primes.append(num) | |
return list_of_primes | |
max_num_to_check = int(input("Search for primes upto: ")) | |
list_of_primes = getPrimes(max_num_to_check) | |
for prime in list_of_primes: | |
print(prime) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment