I need help on getting solution for the below python code. The code gives the required output which is that it dispaly number of prime number that user wants.
if user inputs 4
Actual Output: 2, 3 , 5 , 7
The main question is that I do not have idea on how to give rank to those prime numbers.
The 1st prime number is 2
The 2nd prime number is 3
The 3rd prime number is 5
The 4th prime number is 7
and so on.
Can anyone please help to write the code to get above result. It would be of great help. Thank You.
def isprime(): n = int(input("How many prime numbers do you want?")) counter = 0 i = 1 while True: c = 0 for j in range(1, (i + 1), 1): a = i % j if (a == 0): c = c + 1 if (c == 2): print(i) counter = counter + 1 if counter >= n: break i = i + 1 isprime()