Prime numbers in range
Prime number is a number which is divisible by one and itself. In this program we are finding prime numbers in the given range.
Program
def prime(n): if(n==0 or n==1): return 0 elif(n==2): return 1 else: for i in range(2,int(n**0.5)+1): if(n%i==0): return 0 else: return 1 ll=int(input('Enter the lower limit ')) ul=int(input('Enter the upper limit ')) for i in range(ll,ul+1): if(prime(i)): print(i,end=" ")Output 1
Enter the lower limit 10 Enter the upper limit 120 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113Output 2
Enter the lower limit 50 Enter the upper limit 500 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499
0 comments :
Post a Comment
Note: only a member of this blog may post a comment.