I want to write a code that will take user input for N which is the total number of prime numbers to print out. I have executed the below code, but the output is wrong:
#For example, the user enters the value of N = 7.
#Desired output: 2, 3, 5, 7, 11, 13, 19
#Actual output: 2, 3, 5, 7
#Kindly advise.
i = 1
x = int(input("Enter the number:"))
for k in range(1, x+1):
c = 0
for j in range(1, i+1):
a = i % j
if a == 0:
c = c + 1
if c == 2:
print(i)
else:
k = k - 1
i = i + 1