To find first N prime numbers in python

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

    max = input("enter the maximum limit to check prime number");
    if max>1 :
        for i in range (2,max):
            prime=0;
            for j in range (2,i):
                if(i%j==0):
                    prime=1;
                    break
            if(prime==0 and i!=0):
                print(i,"is prime number");
    else:
        print("prime no start from 2");
    

提交回复
热议问题