Advertisement
ruhan008

Python Assignment 2

Feb 2nd, 2024 (edited)
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. prime_pos = 10001
  2. req_prime = -1
  3. number = 2
  4. while(1):
  5.     i = 2
  6.     isPrime = 1
  7.     while((i*i)<=number):
  8.         if((number%i) == 0):
  9.             isPrime = 0
  10.             break;
  11.  
  12.         i = i + 1
  13.    
  14.     if(isPrime):
  15.         req_prime = number
  16.         prime_pos = prime_pos - 1
  17.  
  18.         if(prime_pos == 0):
  19.             break;
  20.     number = number + 1
  21.  
  22. print("The 10001st prime is:",req_prime);
  23.  
  24. # OUTPUT:
  25.  
  26. # The 10001st prime is: 104743
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement