SHARE
TWEET

Untitled

a guest Nov 12th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def primeChecker(x):
  2.     factorCount = 0
  3.     y = int(x)
  4.     for i in range (2,y):
  5.         if (x % i) == 0:
  6.             factorCount = factorCount + 1
  7.     if factorCount == 0:
  8.         return 1
  9.     else:
  10.         return 0
  11.  
  12. intCheck = False
  13. primeCheck = 0
  14. while intCheck == False:
  15.   print("even number")
  16.   number = input()
  17.   try:
  18.     number = int(number)
  19.     intCheck = True
  20.   except:
  21.     print("only enter numbers")
  22.  
  23.   try:
  24.     evenCheck = number % 2
  25.     if evenCheck != 0:
  26.       print("number must be even")
  27.       intCheck = False
  28.   except:
  29.     intCheck = False
  30.  
  31. prime1 = number / 2
  32. prime2 = number / 2
  33.  
  34. while primeCheck != 2:
  35.   primeCheck = 0
  36.   primeCheck = primeCheck + primeChecker(prime1)
  37.   primeCheck = primeCheck + primeChecker(prime2)        
  38.   if primeCheck != 2:
  39.     prime1 = prime1 + 1
  40.     prime2 = prime2 - 1
  41.  
  42. print("the 2 primes which add to ",number," are ",prime1," & ",prime2)
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