To find first N prime numbers in python

前端 未结 29 2321
醉梦人生
醉梦人生 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:38

    n=int(input("Enter the number:: "))
    
    for i in range(2,n):
        p=i
        k=0
        for j in range(2,p-1):
            if(p%j==0):
                k=k+1
        if(k==0):
            print(p)
    

提交回复
热议问题