def main(): import math import trialDivision i = 9 while 1: successFlag = 1 if not trialDivision.main(i): for j in range(1, math.ceil(math.sqrt(i // 2))): if trialDivision.main(i - 2 * (j**2)): successFlag = 0 if successFlag: print(i) break i = i + 2
def main(): import trialDivision maxChain = 0 storeI = 0 storeJ = 0 for i in range(-1000, 1000): for j in range(-999, 999): n = 0 while 1: evaluate = (n * n + j * n + i) if (evaluate <= 1): if (n > maxChain): maxChain = n storeI = i storeJ = j break if (trialDivision.main(evaluate) == 0): if (n > maxChain): maxChain = n storeI = i storeJ = j break n = n + 1 print(maxChain) print(storeI) print(storeJ)
def main(): import trialDivision primeArray = [] for i in range(1,10000): if (trialDivision.main(i) == 1): primeArray.append(i) primeAmount = len(primeArray) relationGrid = [] for A in range(primeAmount): truthVector = [] for B in range(primeAmount): if concatenate(primeArray[A],primeArray[B]): truthVector.append(1) else: truthVector.append(0) relationGrid.append(truthVector) for a in range(primeAmount): for b in range(a+1,primeAmount): if relationGrid[a][b] and relationGrid[b][a]: for c in range(b+1,primeAmount): if relationGrid[a][c] and relationGrid[c][a] and relationGrid[b][c] and relationGrid[c][b]: for d in range(c+1,primeAmount): if relationGrid[a][d] and relationGrid[d][a] and relationGrid[b][d] and relationGrid[d][b] and relationGrid[c][d] and relationGrid[d][c]: for e in range(d+1,primeAmount): if relationGrid[a][e] and relationGrid[e][a] and relationGrid[b][e] and relationGrid[e][b] and relationGrid[c][e] and relationGrid[e][c] and relationGrid[d][e] and relationGrid[e][d]: print(primeArray[a]) print(primeArray[b]) print(primeArray[c]) print(primeArray[d]) print(primeArray[e])
def main(): import trialDivision import itertools import time t = time.time() i = 101 while i < 100000: print(i) numString = str(i) for j in itertools.combinations(range(5), 2): baseList = ["*", "*", "*", "*", "*", "*"] baseList[j[0]] = numString[0] baseList[j[1]] = numString[1] baseList[5] = numString[2] compositeCounter = 0 for m in range(10): newList = [str(m) if x == "*" else x for x in baseList] result = int(''.join(newList)) if (trialDivision.main(result) == 0) and (result > 100000): compositeCounter = compositeCounter + 1 if compositeCounter > 2: break if (compositeCounter < 2) and (m == 9): print(time.time() - t) return result i = i + 2
def main(): import trialDivision import itertools for i in range(1000, 10000): if trialDivision.main(i): numString = str(i) perms = list( set(list(''.join(p) for p in itertools.permutations(numString)))) perms.sort() perms = perms[1 + perms.index(numString):] for j in perms: if (trialDivision.main(int(j)) and trialDivision.main(2 * int(j) - i) and (str(2 * int(j) - i) in perms)): print(numString + j + str(2 * int(j) - i))
def main(): import itertools import trialDivision digitList = [1, 2, 3, 4, 5, 6, 7] perms = itertools.permutations(digitList) maxNum = 0 for i in perms: numString = ''.join(str(j) for j in i) num = int(numString) if (trialDivision.main(num) == 1): maxNum = num print(maxNum)
def main(): import trialDivision primes = 0 counter = 1 while (10 * primes) > (4 * counter - 3) or counter < 2: diagNumber = (2 * counter - 1)**2 for i in range(4): diagNumber = diagNumber + 2 * counter if trialDivision.main(diagNumber) == 1: primes = primes + 1 counter = counter + 1 print(primes / (4 * counter - 3)) return (2 * counter - 1)
def main(): import trialDivision total = 0 ticks = 0 i = 10 while (ticks < 11): if (trialDivision.main(i)): forwardString = str(i) backwardString = forwardString successFlag = 1; for j in range(1,len(forwardString)): forwardString = forwardString[:-1] backwardString = backwardString[1:] if trialDivision.main(int(forwardString)) == 0 or trialDivision.main(int(backwardString)) == 0: successFlag = 0 if successFlag: print(i) total = total + i ticks = ticks + 1 i = i + 1 print(total)
def main(cap): import trialDivision primeList = [] for i in range(1,cap): if trialDivision.main(i): primeList.append(i) sumList = [] total = 0 sumList.append(0) for j in primeList: total = total + j sumList.append(total) maxChain = 0 maxPrime = 0 for k in range(0,len(sumList)): for l in range(maxChain+1,k+1): if (sumList[k] - sumList[k-l])>cap: break if (trialDivision.main(sumList[k] - sumList[k-l])): maxChain = l maxPrime = sumList[k] - sumList[k-l] print(maxChain) print(maxPrime)
def circularPrimes(length): import trialDivision digitSet = [1, 3, 7, 9] total = 0 for i in range(0, 4**length): number = 0 for k in range(0, length): number = number + (10**k) * digitSet[i % 4] i = i // 4 primeFlag = 1 for j in range(0, length): number = (10**(length - 1)) * (number % 10) + number // 10 if (trialDivision.main(number) == 0): primeFlag = 0 break if primeFlag: total = total + 1 return total
def concatenate(int1,int2): import trialDivision return trialDivision.main(int(str(int1)+str(int2))) == 1