summaryrefslogtreecommitdiff
path: root/Problem51.py
diff options
context:
space:
mode:
Diffstat (limited to 'Problem51.py')
-rw-r--r--Problem51.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/Problem51.py b/Problem51.py
new file mode 100644
index 0000000..da9410c
--- /dev/null
+++ b/Problem51.py
@@ -0,0 +1,38 @@
+#Unfinished
+import math
+def isPrime(n):
+ if n < 2: return False
+ for x in range(2,int(math.sqrt(n)+1)):
+ if n%x == 0: return False
+ return True
+def nextPrime(n):
+ n+=1
+ while isPrime(n) == False:
+ n+=1
+ return n
+def countReplacementPrimes(n):
+ strn = str(n)
+ primecount = 0
+ m = ""
+ largestPrimeCount = 0
+ for x in range(0,len(strn)): #selects position to be swapped
+ primecount = 0
+ for replacementValue in range(0, 10): #increments replacement value
+ m = ""
+ for y in range(0,len(strn)): #selects location within passed number
+ if y == x:
+ m += str(replacementValue)
+ else:
+ m += strn[y]
+ if(isPrime(int(m))) == True: primecount +=1
+ if primecount == 8: return True
+ return False
+print(countReplacementPrimes(121313))
+#print(isPrime(int("70")))
+# x = nextPrime(0)
+# while countReplacementPrimes(x) == False:
+# x = nextPrime(x)
+# print(x)
+
+
+ \ No newline at end of file