This is the code:
def simplify(num_1):
factors = []
num_1 = abs(num_1)
if num_1 == 1 or num_1 == 0:
return 'Non-Prime-Non-Composite'
for i in range(1, num_1 + 1):
if num_1 % i == 0:
factors.append(i)
if len(factors) == 2:
return 'Prime'
return 'Composite'
usr = int(input("Enter 'n'th prime number to find: "))
n = 0
iter = 0
while n != usr:
iter+=1
if simplify(iter) == 'Prime':
n+=1
print(iter)
I’m trying to find an efficient way to get prime numbers by their position on the number line of prime numbers (if you get what im saying)… Is this close? Also, importing new modules won’t count as im trying to rebuild it from scratch…
It did what it did…
New contributor
Rohan Balaji is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.