Skip to content

Commit

Permalink
Add: List prime numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroSato committed Oct 10, 2022
1 parent 42bb39b commit d28a45d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Programs/prime_numbers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

# Author: Álvaro Masanori Sato

def is_prime(num):
for n in range(2, num):
if num % n == 0:
return False
return True

if __name__ == "__main__":
prime_num = input("How many prime numbers do you want?: ")


if(prime_num.strip().isdigit()):
prime_num = int(prime_num)
if(prime_num < 2):
print("No prime numbers bellow 2")
else:
prime = []
prime_len = 0
i = 2
while(prime_len < prime_num):
if(is_prime(i)):
prime.append(i)
prime_len = prime_len + 1
i = i + 1

else:
print("Your input it's not a number!!!")

print(prime)

0 comments on commit d28a45d

Please sign in to comment.