To find first N prime numbers in python

前端 未结 29 2195
醉梦人生
醉梦人生 2020-11-28 06:56

I am new to the programming world. I was just writing this code in python to generate N prime numbers. User should input the value for N which is the total number of prime n

29条回答
  •  自闭症患者
    2020-11-28 07:57

    Hi! I am very new to coding, just started 4 days back. I wrote a code to give back the first 1000 prime numbers including 1. Have a look

    n=1
    c=0
    while n>0:
       for i in range(2,n):
          if n%i == 0:
             break
       else:
          print(n,'is a prime')
          c=c+1
       n=n+1
       if c==1000:
          break
    

提交回复
热议问题