SHARE
TWEET

Untitled

a guest Jul 18th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. b = 2
  2.  
  3. while b < 3:
  4.  
  5.     def prime():
  6.        
  7.         if intnumber == 2:
  8.             return str("\n2 is a prime number.\n")
  9.                        
  10.         elif intnumber < 2:
  11.             return str("\nProgram needs numbers greater than two.\n")                
  12.        
  13.         elif intnumber > 2:
  14.             for x in range(2, intnumber-1):
  15.                 if intnumber % x != 0:
  16.                     continue                      
  17.                
  18.                 elif intnumber % x == 0:
  19.                     return str("\nThis is not a prime number because " + str(number) + " divided by " + str(x) + " has a remainder of zero.\n")
  20.            
  21.             return str("\nThis is a prime number.\n")
  22.  
  23.     number = (input('Please type a number and I will tell you if it is prime or not. Type "Exit" to exit the program: '))
  24.    
  25.     try:
  26.         intnumber = int(number)
  27.         result = prime()
  28.         print(result)
  29.         continue
  30.    
  31.     except ValueError:
  32.         if number == 'Exit':
  33.             print('\nYou have chosen to end the program. Goodbye.')
  34.             break
  35.        
  36.         elif number != "Exit":
  37.             print('\nPlease either type "Exit" or a number.\n')
  38.             continue
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top