Prime number generation between 1 to n in python programming


#Prime Number generator between two numbers------#Alamgir Hossain#CSE, JUST
print "To print all prime number between 1 to N ------- "N = input("Enter the value of N : ")

print "Prime number between 1 to ",N," ..... "if N==1:
    isprime = 1for i in range(2,N+1):
    isprime = 0
    for j in range(2,i/2+1):
        if i%j==0:
            isprime = 1            break
    if isprime==0:
        print i," "

No comments:

Post a Comment